Spaces:
Runtime error
Runtime error
| """ | |
| 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"] | |