rafaa commited on
Commit
4d5f9d4
·
verified ·
1 Parent(s): 8020525

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -11,6 +11,7 @@ elevenlabs_api_key = os.environ.get("ELEVEN_KEY_TOKEN", None)
11
  voice_id_before = os.environ.get("VOICE_ID", None)
12
  ttsPassword = os.environ.get("TTS_PASSWORD", None)
13
  password = ''
 
14
 
15
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
16
 
@@ -148,7 +149,7 @@ def generate_text(
148
 
149
  if password == ttsPassword:
150
  print("Using TTS!")
151
- audio_output = generate_voice(output, voice_id_before, elevenlabs_api_key)
152
  # Create a tuple message with the output and the audio output
153
  output_message = (output, (audio_output, "This is an audio file"))
154
  elif password != ttsPassword and password != '':
@@ -156,7 +157,7 @@ def generate_text(
156
  else:
157
  print("Not using TTS!")
158
 
159
- return output, audio_output
160
 
161
 
162
 
@@ -173,8 +174,7 @@ with gr.ChatInterface(
173
  additional_inputs=[passwordInput],
174
  ):
175
  audioBlock = gr.Audio(autoplay=True, interactive=False)
176
- audioBlock.value = generate_text(prompt, history, passwordInput, temperature=0.2, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0
177
- )
178
 
179
 
180
  chat.launch(show_api=False)
 
11
  voice_id_before = os.environ.get("VOICE_ID", None)
12
  ttsPassword = os.environ.get("TTS_PASSWORD", None)
13
  password = ''
14
+ lastAudio = None
15
 
16
  client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
17
 
 
149
 
150
  if password == ttsPassword:
151
  print("Using TTS!")
152
+ lastAudio = generate_voice(output, voice_id_before, elevenlabs_api_key)
153
  # Create a tuple message with the output and the audio output
154
  output_message = (output, (audio_output, "This is an audio file"))
155
  elif password != ttsPassword and password != '':
 
157
  else:
158
  print("Not using TTS!")
159
 
160
+ return output
161
 
162
 
163
 
 
174
  additional_inputs=[passwordInput],
175
  ):
176
  audioBlock = gr.Audio(autoplay=True, interactive=False)
177
+ audioBlock.value = lastAudio
 
178
 
179
 
180
  chat.launch(show_api=False)