Baghdad99 commited on
Commit
cd07de6
1 Parent(s): c23e905

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -25,12 +25,20 @@ def translate_speech(audio_data_tuple):
25
  # Use the speech recognition model to transcribe the audio
26
  output = model.transcribe([temp_audio_file.name])
27
  print(f"Output: {output}") # Print the output to see what it contains
28
-
29
- # ... (rest of your code)
30
-
 
 
 
 
 
 
 
 
31
 
32
  # Use the translation pipeline to translate the transcription
33
- translated_text = translator(output, return_tensors="pt")
34
  print(f"Translated text: {translated_text}") # Print the translated text to see what it contains
35
 
36
  # Check if the translated text contains 'generated_token_ids'
 
25
  # Use the speech recognition model to transcribe the audio
26
  output = model.transcribe([temp_audio_file.name])
27
  print(f"Output: {output}") # Print the output to see what it contains
28
+ # Use the speech recognition model to transcribe the audio
29
+ output = model.transcribe(audio_data)
30
+ print(f"Output: {output}") # Print the output to see what it contains
31
+
32
+ # Check if the output contains 'transcription'
33
+ if 'transcription' in output:
34
+ transcription = output["transcription"]
35
+ else:
36
+ print("The output does not contain 'transcription'")
37
+ return
38
+
39
 
40
  # Use the translation pipeline to translate the transcription
41
+ translated_text = translator(transciption, return_tensors="pt")
42
  print(f"Translated text: {translated_text}") # Print the translated text to see what it contains
43
 
44
  # Check if the translated text contains 'generated_token_ids'