ANASAKHTAR commited on
Commit
5f19733
·
verified ·
1 Parent(s): 9b7823a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -42,12 +42,12 @@ def translate_text(text, destination_language):
42
 
43
  translation = text_translator(text, src_lang="eng_Latn", tgt_lang=dest_code)
44
  return translation[0]["translation_text"]
 
45
 
46
- # Speech-to-text pipeline
47
  speech_to_text = pipeline(
48
  "automatic-speech-recognition",
49
- model="openai/whisper-small",
50
- language="en"
51
  )
52
 
53
  # Function to transcribe audio to text
@@ -55,6 +55,7 @@ def transcribe_audio(audio_file, destination_language):
55
  transcription = speech_to_text(audio_file)["text"]
56
  return translate_text(transcription, destination_language)
57
 
 
58
  # Gradio interface
59
  with gr.Blocks() as demo:
60
  gr.Markdown("# AI-Powered Language Translation Bot")
 
42
 
43
  translation = text_translator(text, src_lang="eng_Latn", tgt_lang=dest_code)
44
  return translation[0]["translation_text"]
45
+ from transformers import pipeline
46
 
47
+ # Initialize the speech-to-text pipeline
48
  speech_to_text = pipeline(
49
  "automatic-speech-recognition",
50
+ model="openai/whisper-small"
 
51
  )
52
 
53
  # Function to transcribe audio to text
 
55
  transcription = speech_to_text(audio_file)["text"]
56
  return translate_text(transcription, destination_language)
57
 
58
+
59
  # Gradio interface
60
  with gr.Blocks() as demo:
61
  gr.Markdown("# AI-Powered Language Translation Bot")