Yusin commited on
Commit
459d2d6
1 Parent(s): 5497f7b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -8
app.py CHANGED
@@ -41,14 +41,12 @@ def chat_hf(audio, custom_token, language):
41
  gpt_response = """Sorry, I'm quite busy right now, but please try again later :)"""
42
 
43
  # to voice
44
- print(language)
45
  if language == 'cn' or 'jp':
46
- voice_out = cn_a_jp(gpt_response)
47
  else:
48
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
49
  coquiTTS.get_tts(gpt_response, fp, speaker = {"language" : language})
50
  voice_out = fp.name
51
-
52
  return whisper_text, gpt_response, voice_out
53
 
54
  # whisper
@@ -108,18 +106,17 @@ with gr.Blocks() as blocks:
108
  + title
109
  + "</h1>")
110
  #gr.Markdown(description)
111
- radio = gr.Radio(label="Language",choices=LANGUAGES,value=default_lang)
112
  with gr.Row(equal_height=True):# equal_height=False
113
  with gr.Column():# variant="panel"
114
- audio_file = gr.Audio(source="microphone",type="filepath")
115
  custom_token = gr.Textbox(label='If it fails, use your own session token', placeholder="your own session token")
116
  with gr.Row():# mobile_collapse=False
117
  submit = gr.Button("Submit", variant="primary")
118
  with gr.Column():
119
  text1 = gr.Textbox(label="Speech to Text")
120
  text2 = gr.Textbox(label="ChatGPT Response")
121
- audio = gr.Audio(label="Output")
122
- #audio = gr.Audio(label="Output", interactive=False)
123
  #gr.Markdown(info)
124
  #gr.Markdown("<center>"
125
  # +f'<img src={badge} alt="visitors badge"/>'
@@ -131,7 +128,7 @@ with gr.Blocks() as blocks:
131
  [audio_file, custom_token, radio],
132
  [text1, text2, audio],
133
  )
134
- radio.change(lambda lang: CoquiTTS.langs[lang]["sentence"], radio, text2)
135
 
136
 
137
  blocks.launch(debug=True)
 
41
  gpt_response = """Sorry, I'm quite busy right now, but please try again later :)"""
42
 
43
  # to voice
 
44
  if language == 'cn' or 'jp':
45
+ voice_out = cn_a_jp(gpt_response, fn_index=0)
46
  else:
47
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
48
  coquiTTS.get_tts(gpt_response, fp, speaker = {"language" : language})
49
  voice_out = fp.name
 
50
  return whisper_text, gpt_response, voice_out
51
 
52
  # whisper
 
106
  + title
107
  + "</h1>")
108
  #gr.Markdown(description)
109
+ radio = gr.Radio(label="Language", choices=LANGUAGES, value=default_lang)
110
  with gr.Row(equal_height=True):# equal_height=False
111
  with gr.Column():# variant="panel"
112
+ audio_file = gr.Audio(source="microphone", type="filepath")
113
  custom_token = gr.Textbox(label='If it fails, use your own session token', placeholder="your own session token")
114
  with gr.Row():# mobile_collapse=False
115
  submit = gr.Button("Submit", variant="primary")
116
  with gr.Column():
117
  text1 = gr.Textbox(label="Speech to Text")
118
  text2 = gr.Textbox(label="ChatGPT Response")
119
+ audio = gr.Audio(label="Output", interactive=False)
 
120
  #gr.Markdown(info)
121
  #gr.Markdown("<center>"
122
  # +f'<img src={badge} alt="visitors badge"/>'
 
128
  [audio_file, custom_token, radio],
129
  [text1, text2, audio],
130
  )
131
+ #radio.change(lambda lang: CoquiTTS.langs[lang]["sentence"], radio, text2)
132
 
133
 
134
  blocks.launch(debug=True)