Giọng Nói
Whisper AI 2025: Speech-to-Text chuẩn nhất - Chuyển đổi audio thành text với độ chính xác 95%+
Admin Manager
•21 tháng 12, 2025
•5 phút đọc
•0 lượt xem
#TTS #Giọng nói AI
Whisper AI của OpenAI là mô hình Speech-to-Text (STT) mã nguồn mở tốt nhất hiện nay, hỗ trợ 99 ngôn ngữ với độ chính xác vượt trội.
PHẦN 1: WHISPER AI LÀ GÌ?
Định nghĩa:
Whisper là mô hình AI của OpenAI chuyên chuyển đổi:
- Speech-to-Text: Audio → Text.
- Translation: Audio ngôn ngữ A → Text tiếng Anh.
- Language Detection: Tự động nhận diện ngôn ngữ.
Điểm mạnh:
- Mã nguồn mở: Miễn phí, chạy local.
- Đa ngôn ngữ: 99 ngôn ngữ (bao gồm tiếng Việt).
- Chính xác: 95%+ với audio chất lượng tốt.
- Robust: Xử lý tốt nhiễu, giọng địa phương, từ chuyên ngành.
PHẦN 2: CÁC MODEL WHISPER
OpenAI cung cấp 5 model với kích thước khác nhau:
| Model | Size | VRAM | Speed | Accuracy |
|---|---|---|---|---|
| tiny | 39M | ~1GB | Rất nhanh | ⭐⭐⭐ |
| base | 74M | ~1GB | Nhanh | ⭐⭐⭐⭐ |
| small | 244M | ~2GB | Trung bình | ⭐⭐⭐⭐ |
| medium | 769M | ~5GB | Chậm | ⭐⭐⭐⭐⭐ |
| large | 1550M | ~10GB | Rất chậm | ⭐⭐⭐⭐⭐ |
Khuyến nghị:
- Realtime: tiny, base.
- Batch processing: medium, large.
- Production: medium (cân bằng tốc độ & chất lượng).
PHẦN 3: CÀI ĐẶT & SỬ DỤNG
Cài đặt:
# Cài đặt Whisper
pip install openai-whisper
# Hoặc dùng faster-whisper (nhanh hơn 4x)
pip install faster-whisper
Sử dụng CLI:
# Transcribe audio file
whisper audio.mp3 --model medium --language Vietnamese
# Translate sang tiếng Anh
whisper audio.mp3 --model medium --task translate
# Output formats: txt, srt, vtt, json
whisper audio.mp3 --model medium --output_format srt
Sử dụng Python:
Example 1: Basic Transcription
import whisper
# Load model
model = whisper.load_model("medium")
# Transcribe
result = model.transcribe("audio.mp3", language="vi")
# Print text
print(result["text"])
# Print segments (với timestamp)
for segment in result["segments"]:
print(f"[{segment['start']:.2f}s - {segment['end']:.2f}s] {segment['text']}")
Example 2: Faster Whisper (4x nhanh hơn)
from faster_whisper import WhisperModel
# Load model (chạy trên GPU nếu có)
model = WhisperModel("medium", device="cuda", compute_type="float16")
# Transcribe
segments, info = model.transcribe("audio.mp3", language="vi")
# Print
for segment in segments:
print(f"[{segment.start:.2f}s - {segment.end:.2f}s] {segment.text}")
Example 3: OpenAI API (Whisper-1)
from openai import OpenAI
client = OpenAI(api_key="your_api_key")
# Transcribe
with open("audio.mp3", "rb") as audio_file:
transcript = client.audio.transcriptions.create(
model="whisper-1",
file=audio_file,
language="vi"
)
print(transcript.text)
PHẦN 4: USE CASES THỰC TẾ
1. Phụ đề Video (Subtitle)
Workflow:
- Tách audio từ video (ffmpeg).
- Transcribe bằng Whisper → SRT file.
- Embed subtitle vào video.
Code:
import whisper
import subprocess
# Extract audio
subprocess.run([
"ffmpeg", "-i", "video.mp4",
"-vn", "-acodec", "pcm_s16le",
"audio.wav"
])
# Transcribe
model = whisper.load_model("medium")
result = model.transcribe("audio.wav", language="vi")
# Save SRT
with open("subtitle.srt", "w", encoding="utf-8") as f:
for i, segment in enumerate(result["segments"], 1):
start = format_timestamp(segment["start"])
end = format_timestamp(segment["end"])
text = segment["text"]
f.write(f"{i}\n{start} --> {end}\n{text}\n\n")
2. Meeting Transcription
Workflow:
- Record meeting (Zoom, Google Meet).
- Transcribe → Text.
- Tóm tắt bằng ChatGPT.
Code:
import whisper
from openai import OpenAI
# Transcribe meeting
model = whisper.load_model("medium")
result = model.transcribe("meeting.mp3", language="vi")
transcript = result["text"]
# Summarize với ChatGPT
client = OpenAI()
summary = client.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": "Tóm tắt cuộc họp"},
{"role": "user", "content": transcript}
]
)
print(summary.choices[0].message.content)
3. Podcast Transcription
Workflow:
- Upload podcast MP3.
- Transcribe → Blog post.
- SEO optimize.
4. Voice Command (Chatbot)
Workflow:
- User nói → Whisper → Text.
- Text → ChatGPT → Response.
- Response → ElevenLabs → Audio.
PHẦN 5: SO SÁNH VỚI CÔNG CỤ KHÁC
| Tiêu chí | Whisper | Google STT | Azure STT | AssemblyAI |
|---|---|---|---|---|
| Chính xác | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| Ngôn ngữ | 99 | 125+ | 100+ | 50+ |
| Giá | Free (local) | $0.006/15s | $1/giờ | $0.00025/s |
| Mã nguồn mở | ✅ | ❌ | ❌ | ❌ |
| Chạy local | ✅ | ❌ | ❌ | ❌ |
| Realtime | ❌ | ✅ | ✅ | ✅ |
Kết luận:
- Whisper: Tốt nhất cho batch processing, miễn phí.
- Google/Azure: Tốt cho realtime, streaming.
PHẦN 6: TIPS & OPTIMIZATION
1. Tăng tốc độ:
Dùng faster-whisper:
- Nhanh hơn 4x so với Whisper gốc.
- Dùng CTranslate2 (C++ backend).
Dùng GPU:
model = WhisperModel("medium", device="cuda")
Batch processing:
# Transcribe nhiều file cùng lúc
files = ["audio1.mp3", "audio2.mp3", "audio3.mp3"]
for file in files:
result = model.transcribe(file)
2. Tăng độ chính xác:
Chỉ định ngôn ngữ:
result = model.transcribe("audio.mp3", language="vi")
Prompt (gợi ý context):
result = model.transcribe(
"audio.mp3",
language="vi",
initial_prompt="Cuộc họp về AI, Machine Learning, Deep Learning"
)
Dùng VAD (Voice Activity Detection):
result = model.transcribe(
"audio.mp3",
vad_filter=True # Lọc phần im lặng
)
3. Xử lý audio chất lượng kém:
Noise reduction (ffmpeg):
ffmpeg -i noisy.mp3 -af "highpass=f=200, lowpass=f=3000" clean.mp3
Normalize volume:
ffmpeg -i quiet.mp3 -af "loudnorm" loud.mp3
PHẦN 7: WHISPER API (OPENAI)
Pricing:
- $0.006 / phút (rẻ hơn chạy local nếu bạn không có GPU).
Giới hạn:
- File size: Tối đa 25MB.
- Thời lượng: Không giới hạn (nhưng phải < 25MB).
Code Example:
from openai import OpenAI
client = OpenAI(api_key="your_api_key")
# Transcribe
with open("audio.mp3", "rb") as audio_file:
transcript = client.audio.transcriptions.create(
model="whisper-1",
file=audio_file,
language="vi",
response_format="verbose_json" # Có timestamp
)
# Print segments
for segment in transcript.segments:
print(f"[{segment['start']}s] {segment['text']}")
PHẦN 8: CHALLENGES & SOLUTIONS
Challenge 1: Tốc độ chậm
Solution:
- Dùng faster-whisper.
- Dùng GPU.
- Dùng model nhỏ hơn (base, small).
Challenge 2: Tiếng Việt không chính xác
Solution:
- Dùng model medium hoặc large.
- Thêm initial_prompt với từ khóa tiếng Việt.
- Xử lý audio trước (noise reduction).
Challenge 3: File quá lớn
Solution:
- Chia nhỏ file (ffmpeg).
- Dùng Whisper API (không giới hạn thời lượng).
KẾT LUẬN
Whisper AI là công cụ STT tốt nhất cho:
- Developer: Tích hợp vào app, chatbot.
- Content Creator: Tạo phụ đề, transcribe podcast.
- Researcher: Transcribe interview, meeting.
Lời khuyên:
- Dùng faster-whisper thay vì whisper gốc (nhanh hơn 4x).
- Dùng medium model cho production (cân bằng tốc độ & chất lượng).
- Kết hợp với ChatGPT để tóm tắt, phân tích transcript.
Chia sẻ
Nhận tin mới nhất
Cập nhật AI & Tech hàng tuần