|
import assemblyai as aai |
|
|
|
|
|
aai.settings.api_key = "2c02e1bdab874068bdcfb2e226f048a4" |
|
|
|
def transcribe_audio(file_path: str, language, model_size=None) -> str: |
|
|
|
print(f"Transcribing audio file: {file_path} with language: {language}") |
|
|
|
config = aai.TranscriptionConfig( |
|
speech_model=aai.SpeechModel.nano, |
|
language_code=language |
|
) |
|
|
|
|
|
transcriber = aai.Transcriber(config=config) |
|
|
|
|
|
transcript = transcriber.transcribe(file_path) |
|
|
|
|
|
if transcript.status == "error": |
|
raise RuntimeError(f"Transcription failed: {transcript.error}") |
|
|
|
|
|
return transcript.text |
|
|