Spaces:
Runtime error
Runtime error
File size: 574 Bytes
eeb0f9c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
"""
Speech-to-Text Module
Handles audio recording and speech recognition using Hugging Face
"""
import logging
from transformers import pipeline
logger = logging.getLogger(__name__)
model_id = "vinai/PhoWhisper-base"
pipe = pipeline("automatic-speech-recognition", model=model_id)
def transcribe_speech(filepath):
output = pipe(
filepath,
max_new_tokens=256,
generate_kwargs={
"task": "transcribe",
"language": "vietnamese",
},
chunk_length_s=30,
batch_size=8,
)
return output["text"]
|