meandyou200175 commited on
Commit
8c58b29
·
verified ·
1 Parent(s): 9de31f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -5
app.py CHANGED
@@ -23,13 +23,25 @@ def bot_audio_interface(wav):
23
  with open(audio_path, "wb") as audio_file:
24
  audio_file.write(audio_data)
25
  else:
26
- print('kkk')
27
- audio_path =''
28
- text=''
29
- response_text=''
 
 
 
 
 
 
 
 
 
 
 
 
30
  return audio_path, text, response_text
31
  except:
32
- return 'response_audio.wav', 'text', 'response_text'
33
 
34
 
35
  with gr.Blocks() as demo:
 
23
  with open(audio_path, "wb") as audio_file:
24
  audio_file.write(audio_data)
25
  else:
26
+ print('switch')
27
+ url = "https://b434-34-148-80-250.ngrok-free.app/speech_to_speech"
28
+ b64 = encode_file_to_base64(wav)
29
+ data = {"b64": b64}
30
+ print('1')
31
+ response = requests.post(url, json=data)
32
+ print('2')
33
+ if response.status_code == 200:
34
+ json_response = response.json()
35
+ text = json_response.get("text")
36
+ response_text = json_response.get("response")
37
+ audio_base64 = json_response.get("audio_base64")
38
+ audio_data = base64.b64decode(audio_base64)
39
+ audio_path = "response_audio1.wav"
40
+ with open(audio_path, "wb") as audio_file:
41
+ audio_file.write(audio_data)
42
  return audio_path, text, response_text
43
  except:
44
+ return 'final_output.wav', 'text', 'response_text'
45
 
46
 
47
  with gr.Blocks() as demo: