not-lain commited on
Commit
c1f218b
1 Parent(s): e555ad1

switched to filepath audio

Browse files
Files changed (1) hide show
  1. app.py +13 -9
app.py CHANGED
@@ -18,21 +18,25 @@ seamless_client = Client("facebook/seamless_m4t")
18
 
19
 
20
 
21
- def process_speech(audio):
22
  """
23
  processing sound using seamless_m4t
24
  """
25
- print(f"audio : {audio}")
26
- print(f"audio type : {type(audio)}")
27
- audio_name = f"{np.random.randint(0, 100)}.wav"
28
- sr, data = audio
29
- write(audio_name, sr, data.astype(np.int16))
30
-
 
 
 
 
31
  out = seamless_client.predict(
32
  "S2TT",
33
  "file",
34
  None,
35
- audio_name, #audio_name
36
  "",
37
  "French",# source language
38
  "English",# target language
@@ -306,7 +310,7 @@ with gr.Blocks(theme='ParityError/Anime') as iface :
306
  image_output = gr.Markdown(label="output text")
307
  image_button = gr.Button("process image")
308
  with gr.Tab("speech to text translation"):
309
- audio_input = gr.Audio(label="talk in french")
310
  audio_output = gr.Markdown(label="output text")
311
  audio_button = gr.Button("process audio")
312
  text_button.click(process_and_query, inputs=text_input, outputs=text_output)
 
18
 
19
 
20
 
21
+ def process_speech(audio_input):
22
  """
23
  processing sound using seamless_m4t
24
  """
25
+ print(f"audio : {audio_input}")
26
+ print(f"audio type : {type(audio_input)}")
27
+
28
+ try :
29
+ audio_name = f"{np.random.randint(0, 100)}.wav"
30
+ sr, data = audio_input
31
+ write(audio_name, sr, data.astype(np.int16))
32
+ audio_input = audio_name
33
+ except :
34
+ pass
35
  out = seamless_client.predict(
36
  "S2TT",
37
  "file",
38
  None,
39
+ audio_input, #audio_name
40
  "",
41
  "French",# source language
42
  "English",# target language
 
310
  image_output = gr.Markdown(label="output text")
311
  image_button = gr.Button("process image")
312
  with gr.Tab("speech to text translation"):
313
+ audio_input = gr.Audio(label="talk in french",type="filepath",sources="microphone")
314
  audio_output = gr.Markdown(label="output text")
315
  audio_button = gr.Button("process audio")
316
  text_button.click(process_and_query, inputs=text_input, outputs=text_output)