AlexMia commited on
Commit
b171990
1 Parent(s): 6881398

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -18,7 +18,7 @@ def audio_response(text, voice="Sophia"):
18
  url = f"https://{GET_AUDIO_API}/get-audio?text={urllib.parse.quote(text)}&voice={voice.lower()}"
19
  try:
20
  response = requests.get(url)
21
- return gr.Audio(response.content)
22
  except Exception as e:
23
  return f"Ein Fehler mit der GET_AUDIO_API ist aufgetreten: {e}"
24
 
@@ -47,9 +47,10 @@ def bot(chat_msg, history=None, audio_response=False):
47
  stop=None,
48
  )
49
  bot_message = completion.choices[0].message.content
 
50
  if audio_response:
51
  response_audio = audio_response(bot_message, voice="Sophia")
52
- messages.append({"role": "assistant", content=response_audio if not "Ein Fehler mit der GET_AUDIO_API" in response_audio else bot_message})
53
  return "", messages, ""
54
  except Exception as e:
55
  bot_message = f"Fehler: {e}"
 
18
  url = f"https://{GET_AUDIO_API}/get-audio?text={urllib.parse.quote(text)}&voice={voice.lower()}"
19
  try:
20
  response = requests.get(url)
21
+ return response.content
22
  except Exception as e:
23
  return f"Ein Fehler mit der GET_AUDIO_API ist aufgetreten: {e}"
24
 
 
47
  stop=None,
48
  )
49
  bot_message = completion.choices[0].message.content
50
+
51
  if audio_response:
52
  response_audio = audio_response(bot_message, voice="Sophia")
53
+ messages.append({"role": "assistant", "content": (gr.Audio(response_audio) if "Ein Fehler mit der GET_AUDIO_API" not in response_audio else bot_message)})
54
  return "", messages, ""
55
  except Exception as e:
56
  bot_message = f"Fehler: {e}"