not-lain commited on
Commit
74f3ed7
1 Parent(s): 5eb8c4a

fix for audio

Browse files
Files changed (1) hide show
  1. app.py +6 -9
app.py CHANGED
@@ -23,23 +23,20 @@ def process_speech(audio):
23
  """
24
  processing sound using seamless_m4t
25
  """
26
- # audio_name = f"{np.random.randint(0, 100)}.wav"
27
- # sr, data = audio
28
- # write(audio_name, sr, data.astype(np.int16))
29
 
30
- job = seamless_client.submit(
31
  "S2TT",
32
  "file",
33
  None,
34
- audio, #audio_name
35
  "",
36
  "French",# source language
37
  "English",# target language
38
  api_name="/run",
39
  )
40
- with not job.done() :
41
- time.sleep(2)
42
- out = job.get_result()
43
  out = out[1] # get the text
44
  try :
45
  return f"{out}"
@@ -309,7 +306,7 @@ with gr.Blocks(theme='ParityError/Anime') as iface :
309
  image_button = gr.Button("process image")
310
  with gr.Tab("speech to text translation"):
311
  audio_input = gr.Audio(label="talk in french",
312
- sources=["microphone"],type="filepath",)
313
  audio_output = gr.Markdown(label="output text")
314
  audio_button = gr.Button("process audio")
315
  text_button.click(process_and_query, inputs=text_input, outputs=text_output)
 
23
  """
24
  processing sound using seamless_m4t
25
  """
26
+ audio_name = f"{np.random.randint(0, 100)}.wav"
27
+ sr, data = audio
28
+ write(audio_name, sr, data.astype(np.int16))
29
 
30
+ out = seamless_client.predict(
31
  "S2TT",
32
  "file",
33
  None,
34
+ audio_name, #audio_name
35
  "",
36
  "French",# source language
37
  "English",# target language
38
  api_name="/run",
39
  )
 
 
 
40
  out = out[1] # get the text
41
  try :
42
  return f"{out}"
 
306
  image_button = gr.Button("process image")
307
  with gr.Tab("speech to text translation"):
308
  audio_input = gr.Audio(label="talk in french",
309
+ sources=["microphone"],type="numpy",)
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)