RP-Azul commited on
Commit
c8b8068
·
verified ·
1 Parent(s): 1e150f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -18,19 +18,15 @@ def audio_to_text(audio):
18
  # Convert to mono if the audio has more than one channel
19
  if len(audio_data.shape) > 1:
20
  audio_data = np.mean(audio_data, axis=1)
21
-
22
-
23
-
24
  audio_array = np.array(audio_data).astype(np.float32)
25
 
26
  # Transcribe the audio input
27
- transcription = pipe1([audio_array])
28
- transcription_text = transcription['text']
29
 
30
- # Print and return the transcription text
31
  print("Transcription:", transcription_text)
32
  return transcription_text
33
 
34
 
35
  demo = gr.Interface(fn=audio_to_text, inputs=gr.Audio(), outputs="text")
36
- demo.launch(share=True)
 
18
  # Convert to mono if the audio has more than one channel
19
  if len(audio_data.shape) > 1:
20
  audio_data = np.mean(audio_data, axis=1)
 
 
 
21
  audio_array = np.array(audio_data).astype(np.float32)
22
 
23
  # Transcribe the audio input
24
+ transcription = pipe1(audio_array, return_timestamps=True)
25
+ transcription_text = " ".join([segment["text"] for segment in transcription["segments"]])
26
 
 
27
  print("Transcription:", transcription_text)
28
  return transcription_text
29
 
30
 
31
  demo = gr.Interface(fn=audio_to_text, inputs=gr.Audio(), outputs="text")
32
+ demo.launch(share=True)