Skip to main content

Amazon Transcribe

Amazon Transcribe คือบริการแปลงเสียงพูดเป็นข้อความ (Automatic Speech Recognition - ASR) ที่ใช้ Machine Learning ให้ผลลัพธ์แม่นยำสูง รองรับการถอดเสียงแบบ real-time streaming สำหรับแอปพลิเคชันที่ต้องการผลทันที และแบบ batch processing สำหรับไฟล์เสียงและวิดีโอขนาดใหญ่ บริการนี้รองรับกว่า 100 ภาษาและ dialect ต่างๆ ทั่วโลก

Transcribe ยังมีฟีเจอร์เฉพาะทางอย่าง Transcribe Medical สำหรับเนื้อหาทางการแพทย์ และ Call Analytics ที่วิเคราะห์การสนทนาของ call center อย่างละเอียด รวมถึงการตรวจจับ sentiment ของทั้งลูกค้าและ agent การวัด talk time และการตรวจจับ interruptions ซึ่งช่วยให้ผู้บริหาร call center ได้ insight ที่มีคุณค่าสูง

AWS Docs: https://docs.aws.amazon.com/transcribe/latest/dg/what-is.html

สถาปัตยกรรม


ฟีเจอร์หลัก

Real-time Transcription (Streaming)

ถอดเสียงพูดเป็นข้อความแบบ real-time ผ่าน WebSocket หรือ HTTP/2 streaming เหมาะสำหรับแอปที่ต้องการแสดงผลทันทีขณะพูด เช่น live captioning, voice assistant และ real-time dictation

Batch Transcription

ประมวลผลไฟล์เสียง/วิดีโอที่เก็บใน S3 แบบ asynchronous รองรับ MP3, MP4, WAV, FLAC, OGG, WebM และ AMR ไฟล์เสียงสูงสุด 4 ชั่วโมงและขนาดสูงสุด 2 GB

Automatic Language Identification

ตรวจจับภาษาในไฟล์เสียงโดยอัตโนมัติ รองรับการระบุว่าไฟล์เสียงมีหลายภาษา (Multi-language identification) โดยไม่ต้องระบุภาษาล่วงหน้า

Speaker Diarization

ระบุและแยกผู้พูดหลายคนในการสนทนา แสดงผลว่า "SPEAKER_0" พูดอะไรและ "SPEAKER_1" พูดอะไร รองรับผู้พูดสูงสุด 10 คน เหมาะสำหรับการถอดเสียงการประชุมและสัมภาษณ์

Custom Vocabulary

เพิ่มคำศัพท์เฉพาะทางที่ระบบอาจไม่รู้จัก เช่น ชื่อแบรนด์ คำศัพท์เทคนิค หรือชื่อบุคคล ทำให้ความแม่นยำสูงขึ้นสำหรับ domain เฉพาะ รองรับทั้ง word list และ phrases

Custom Language Models

ฝึกโมเดลภาษาเฉพาะทางด้วย text data ของตัวเอง เหมาะสำหรับ domain ที่มีคำศัพท์พิเศษมาก เช่น วงการกฎหมาย วงการแพทย์ หรือ industry เฉพาะ ให้ความแม่นยำสูงกว่า Custom Vocabulary

Content Redaction

ซ่อนข้อมูลส่วนบุคคล (PII) ใน transcript อัตโนมัติ เช่น หมายเลขโทรศัพท์ เลขบัตรเครดิต และ SSN เหมาะสำหรับองค์กรที่ต้องปฏิบัติตาม compliance ต่างๆ

Subtitles Generation

สร้าง subtitle file ในรูปแบบ SRT และ VTT โดยอัตโนมัติพร้อม timestamp สำหรับแต่ละบรรทัด เหมาะสำหรับการสร้าง closed captions ให้วิดีโอ

Transcribe Medical

โมเดลเฉพาะสำหรับถอดเสียงพูดทางการแพทย์ เข้าใจคำศัพท์ทางการแพทย์ ชื่อยา และ clinical terminology ได้อย่างแม่นยำ รองรับทั้ง dictation (แพทย์พูดเพียงคนเดียว) และ conversation (แพทย์กับผู้ป่วย) รองรับ HIPAA compliance

Call Analytics

ฟีเจอร์พิเศษสำหรับวิเคราะห์การสนทนาของ call center ให้ข้อมูลเชิงลึก เช่น:

  • Sentiment Analysis ของทั้งลูกค้าและ agent ตลอดการสนทนา
  • Talk Time สัดส่วนเวลาพูดของแต่ละฝ่าย
  • Interruptions จำนวนครั้งที่ agent หรือลูกค้าพูดแทรก
  • Non-talk Time ช่วงเวลาเงียบในสาย
  • Call Categories จำแนกประเภทของสายโดยอัตโนมัติตาม keyword ที่กำหนด
  • Issues, Action Items, Outcomes สรุปประเด็น สิ่งที่ต้องทำ และผลลัพธ์ของสาย

การติดตั้งและการตั้งค่า

1. เปิดใช้งานผ่าน AWS Console

  1. เข้า AWS Console และค้นหา "Amazon Transcribe"
  2. บริการพร้อมใช้งานทันที ลอง demo ในหน้า Console ได้เลย
  3. สำหรับ Custom Language Model ต้องสร้าง S3 bucket เก็บ training data ก่อน

2. ติดตั้ง boto3 และ dependencies

pip install boto3 amazon-transcribe  # amazon-transcribe สำหรับ streaming

3. IAM Permissions ที่จำเป็น

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"transcribe:StartTranscriptionJob",
"transcribe:GetTranscriptionJob",
"transcribe:ListTranscriptionJobs",
"transcribe:StartStreamTranscription",
"transcribe:StartCallAnalyticsJob",
"transcribe:GetCallAnalyticsJob",
"transcribe:CreateVocabulary",
"transcribe:CreateLanguageModel",
"transcribe:StartMedicalTranscriptionJob"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::my-audio-bucket/*"
}
]
}

4. ตัวอย่างการตั้งค่า boto3

import boto3

transcribe = boto3.client(
service_name='transcribe',
region_name='ap-southeast-1'
)

วิธีใช้งาน

Batch Transcription

import boto3
import time
import json
import urllib.request

transcribe = boto3.client('transcribe', region_name='ap-southeast-1')

# เริ่ม transcription job
response = transcribe.start_transcription_job(
TranscriptionJobName='my-transcription-job-001',
Media={
'MediaFileUri': 's3://my-audio-bucket/meeting-recording.mp3'
},
MediaFormat='mp3',
LanguageCode='th-TH', # ภาษาไทย
Settings={
'ShowSpeakerLabels': True,
'MaxSpeakerLabels': 4, # สูงสุด 4 คนในการประชุม
'ShowAlternatives': False
},
OutputBucketName='my-transcripts-bucket',
OutputKey='transcripts/meeting-001.json'
)

job_name = response['TranscriptionJob']['TranscriptionJobName']
print(f"Job started: {job_name}")

# รอจนเสร็จ
while True:
result = transcribe.get_transcription_job(TranscriptionJobName=job_name)
status = result['TranscriptionJob']['TranscriptionJobStatus']
print(f"Status: {status}")

if status == 'COMPLETED':
transcript_uri = result['TranscriptionJob']['Transcript']['TranscriptFileUri']
# ดาวน์โหลดและแสดงผล
with urllib.request.urlopen(transcript_uri) as response:
transcript_data = json.loads(response.read())
print("\nTranscript:")
print(transcript_data['results']['transcripts'][0]['transcript'])
break
elif status == 'FAILED':
print(f"Error: {result['TranscriptionJob']['FailureReason']}")
break
time.sleep(10)

Real-time Streaming Transcription

import asyncio
from amazon_transcribe.client import TranscribeStreamingClient
from amazon_transcribe.handlers import TranscriptResultStreamHandler
from amazon_transcribe.model import TranscriptEvent

class MyTranscriptHandler(TranscriptResultStreamHandler):
async def handle_transcript_event(self, transcript_event: TranscriptEvent):
results = transcript_event.transcript.results
for result in results:
for alt in result.alternatives:
# แสดงผลแบบ real-time
if not result.is_partial:
print(f"[Final] {alt.transcript}")
else:
print(f"[Partial] {alt.transcript}", end='\r')

async def basic_transcribe():
client = TranscribeStreamingClient(region="ap-southeast-1")

stream = await client.start_stream_transcription(
language_code="th-TH",
media_sample_rate_hz=16000,
media_encoding="pcm",
)

handler = MyTranscriptHandler(stream.output_stream)

async def write_chunks():
# อ่านไฟล์เสียงและส่งเป็น chunks
with open("audio_stream.wav", "rb") as f:
while True:
chunk = f.read(1024 * 16)
if not chunk:
break
await stream.input_stream.send_audio_event(audio_chunk=chunk)
await stream.input_stream.end_stream()

await asyncio.gather(write_chunks(), handler.handle_events())

asyncio.run(basic_transcribe())

Call Analytics

# วิเคราะห์การสนทนา Call Center
response = transcribe.start_call_analytics_job(
CallAnalyticsJobName='call-center-analysis-001',
Media={
'MediaFileUri': 's3://call-recordings/customer-call-20240115.wav'
},
OutputLocation='s3://call-analytics-results/',
DataAccessRoleArn='arn:aws:iam::123456789:role/TranscribeRole',
ChannelDefinitions=[
{'ChannelId': 0, 'ParticipantRole': 'AGENT'},
{'ChannelId': 1, 'ParticipantRole': 'CUSTOMER'}
]
)

# รอผลลัพธ์
job_name = response['CallAnalyticsJob']['CallAnalyticsJobName']
while True:
result = transcribe.get_call_analytics_job(CallAnalyticsJobName=job_name)
status = result['CallAnalyticsJob']['CallAnalyticsJobStatus']
if status == 'COMPLETED':
analytics = result['CallAnalyticsJob']

# แสดงผลการวิเคราะห์
for item in analytics.get('Categories', {}).get('MatchedCategories', []):
print(f"Category matched: {item}")

for char in analytics.get('ConversationCharacteristics', {}).get('Sentiment', []):
print(f"Sentiment - {char['ParticipantRole']}: {char['OverallSentiment']}")
break
time.sleep(10)

Custom Vocabulary

# สร้าง Custom Vocabulary สำหรับคำศัพท์เฉพาะ
response = transcribe.create_vocabulary(
VocabularyName='fintech-vocabulary',
LanguageCode='th-TH',
Phrases=[
'PromptPay',
'SCB Easy',
'KBank',
'ทรูมันนี่',
'ราบรื่น',
'วอลเล็ต'
]
)

# ใช้ vocabulary ใน transcription job
transcribe.start_transcription_job(
TranscriptionJobName='fintech-call-001',
Media={'MediaFileUri': 's3://calls/fintech-call.mp3'},
LanguageCode='th-TH',
Settings={
'VocabularyName': 'fintech-vocabulary'
},
OutputBucketName='my-results'
)

Subtitles Generation

# สร้าง subtitles สำหรับวิดีโอ
response = transcribe.start_transcription_job(
TranscriptionJobName='video-subtitle-job',
Media={'MediaFileUri': 's3://videos/training-video.mp4'},
MediaFormat='mp4',
LanguageCode='th-TH',
Subtitles={
'Formats': ['srt', 'vtt'], # สร้างทั้ง SRT และ VTT
'OutputStartIndex': 1
},
OutputBucketName='subtitles-bucket'
)

ราคา (ประมาณการในบาท)

อัตราแลกเปลี่ยน: 1 USD = 35 บาท

ฟีเจอร์ราคา (USD)ราคา (บาท)หมายเหตุ
Standard Batch$0.024/นาที0.84 บาท/นาที250,000 นาทีแรก/เดือน
Standard Batch (volume)$0.015/นาที0.53 บาท/นาทีหลัง 250,000 นาที
Real-time Streaming$0.024/นาที0.84 บาท/นาที
Transcribe Medical$0.078/นาที2.73 บาท/นาที
Call Analytics$0.035/นาที1.23 บาท/นาที
Toxicity Detection+$0.006/นาที+0.21 บาท/นาทีเพิ่มเติมจาก standard
Custom Language Model Training$0.06/นาที2.10 บาท/นาทีdata processing

Free Tier: 60 นาที/เดือน ใน 12 เดือนแรก

ตัวอย่างการคำนวณ:

  • Call Center วิเคราะห์สาย 5,000 สาย/วัน เฉลี่ย 5 นาที/สาย = 25,000 นาที/วัน
  • ค่าใช้จ่าย Call Analytics = 25,000 × $0.035 = $875/วัน (~30,625 บาท/วัน)
  • ค่าใช้จ่าย Standard = 25,000 × $0.024 = $600/วัน (~21,000 บาท/วัน)

เหมาะสำหรับ

  • Call Center และ Contact Center ที่ต้องการ transcript การสนทนาและวิเคราะห์ quality
  • สื่อและโทรทัศน์ ที่ต้องการสร้าง subtitle และ closed caption อัตโนมัติ
  • แพลตฟอร์ม Video Conferencing สำหรับ real-time captions และ meeting transcripts
  • โรงพยาบาลและคลินิก ที่แพทย์ต้องการบันทึกเวชระเบียนด้วยเสียง
  • การศึกษาและ E-Learning สำหรับ transcript บทเรียนและ lecture
  • ระบบ Accessibility สำหรับผู้พิการทางการได้ยินที่ต้องการ real-time captions

ใช้ร่วมกับ AWS Services

AWS Serviceการผสานรวม
Amazon S3เก็บไฟล์เสียง input และ transcript output
AWS Lambdaประมวลผล Transcribe เมื่อมีไฟล์เสียงใหม่ใน S3
Amazon Comprehendวิเคราะห์ sentiment และ entity จาก transcript
Amazon Translateแปล transcript เป็นภาษาอื่น
Amazon Kinesis Video Streamsส่ง audio stream แบบ real-time
Amazon Connectวิเคราะห์สาย contact center แบบ real-time
Amazon QuickSightสร้าง call center analytics dashboard
AWS Step Functionsสร้าง media processing pipeline

Use Case ตัวอย่าง

1. ระบบวิเคราะห์ Call Center อัตโนมัติ

บริษัทประกันภัยใช้ Transcribe Call Analytics วิเคราะห์การสนทนาระหว่าง agent กับลูกค้ากว่า 5,000 สายต่อวัน ทุกสายถูกบันทึกและส่งเข้า S3 อัตโนมัติ Lambda trigger เรียก Call Analytics API ซึ่งให้ sentiment score ของทั้งสองฝ่าย, จำนวน interruptions, talk time ratio, และ automatic summary ระบบ flag สายที่ลูกค้ามี negative sentiment สูงให้ supervisor review ภายใน 30 นาที ทำให้ CSAT score เพิ่มขึ้น 18% และลด churn rate ลง 12% ภายใน 3 เดือน

2. ระบบ Subtitle อัตโนมัติสำหรับสื่อ

แพลตฟอร์ม streaming ของไทยมี content ใหม่กว่า 200 ชั่วโมง/สัปดาห์ ระบบ S3 trigger Lambda เมื่อ video ใหม่ถูกอัปโหลด Transcribe ถอดเสียงและสร้างไฟล์ SRT อัตโนมัติ จากนั้น Translate แปล subtitle เป็น English สำหรับตลาดต่างประเทศ กระบวนการทั้งหมดใช้เวลาเพียง 30-60 นาทีต่อชั่วโมงของ content แทนที่จะเป็น 2-3 วันที่ใช้กับ human subtitler ลดต้นทุนการผลิต subtitle ลง 85%

3. ระบบบันทึกเวชระเบียนด้วยเสียง

โรงพยาบาลเอกชนขนาดใหญ่ติดตั้งระบบให้แพทย์บันทึกเวชระเบียนด้วยเสียงในห้องตรวจ ใช้ Transcribe Medical streaming ถอดเสียงแบบ real-time บนแท็บเล็ตของแพทย์ ระบบรู้จักชื่อยา อาการ และคำศัพท์ทางการแพทย์ได้แม่นยำ แพทย์สามารถ review transcript ที่แสดงทันทีและแก้ไขถ้าจำเป็น ลดเวลาที่แพทย์ใช้กับงานเอกสารจาก 2 ชั่วโมง/วัน เหลือ 30 นาที ทำให้แพทย์มีเวลากับผู้ป่วยมากขึ้น