Yusin commited on
Commit
1cc7b4a
1 Parent(s): 7010662

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -9,9 +9,10 @@ default_lang = "en"
9
  #import whisper
10
  #whisper_model = whisper.load_model("small")
11
  whisper = gr.Interface.load(name="spaces/sanchit-gandhi/whisper-large-v2")
 
12
  import os
13
  #session_token = os.environ.get('SessionToken')
14
- api = os.environ.get('API_ENDPOINT')
15
 
16
  title = "Speech to ChatGPT to Speech"
17
  #info = "more info at [Neon Coqui TTS Plugin](https://github.com/NeonGeckoCom/neon-tts-plugin-coqui), [Coqui TTS](https://github.com/coqui-ai/TTS)"
@@ -19,13 +20,13 @@ title = "Speech to ChatGPT to Speech"
19
 
20
  coquiTTS = CoquiTTS()
21
 
22
- def call_api(message):
23
- response = requests.get(f'{api}?q={message}')
24
- if response.status_code == 200:
25
-
26
- return str(response.text).split('\n', 2)[2]
27
- else:
28
- return """Sorry, I'm quite busy right now, but please try again later :)"""
29
 
30
 
31
  # ChatGPT
@@ -35,7 +36,8 @@ def chat_hf(audio, custom_token, language):
35
  if whisper_text == "ERROR: You have to either use the microphone or upload an audio file":
36
  gpt_response = "MISSING AUDIO: Record your voice by clicking the microphone button, do not forget to stop recording before sending your message ;)"
37
  else:
38
- gpt_response = call_api(whisper_text)
 
39
  #whisper_text = translate(audio)
40
  #api = ChatGPT(session_token)
41
  #resp = api.send_message(whisper_text)
 
9
  #import whisper
10
  #whisper_model = whisper.load_model("small")
11
  whisper = gr.Interface.load(name="spaces/sanchit-gandhi/whisper-large-v2")
12
+ chatgpt = gr.Interface.load(name="spaces/fffiloni/whisper-to-chatGPT")
13
  import os
14
  #session_token = os.environ.get('SessionToken')
15
+ #api = os.environ.get('API_ENDPOINT')
16
 
17
  title = "Speech to ChatGPT to Speech"
18
  #info = "more info at [Neon Coqui TTS Plugin](https://github.com/NeonGeckoCom/neon-tts-plugin-coqui), [Coqui TTS](https://github.com/coqui-ai/TTS)"
 
20
 
21
  coquiTTS = CoquiTTS()
22
 
23
+ #def call_api(message):
24
+ # response = requests.get(f'{api}?q={message}')
25
+ # if response.status_code == 200:
26
+ #
27
+ # return str(response.text).split('\n', 2)[2]
28
+ # else:
29
+ # return """Sorry, I'm quite busy right now, but please try again later :)"""
30
 
31
 
32
  # ChatGPT
 
36
  if whisper_text == "ERROR: You have to either use the microphone or upload an audio file":
37
  gpt_response = "MISSING AUDIO: Record your voice by clicking the microphone button, do not forget to stop recording before sending your message ;)"
38
  else:
39
+ #gpt_response = call_api(whisper_text)
40
+ gpt_response = chatgpt(audio, "transcribe", fn_index=0)
41
  #whisper_text = translate(audio)
42
  #api = ChatGPT(session_token)
43
  #resp = api.send_message(whisper_text)