Yusin commited on
Commit
a0df246
1 Parent(s): cb1da52

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -7,15 +7,13 @@ default_lang = "en"
7
  #import whisper
8
  #whisper_model = whisper.load_model("small")
9
  whisper = gr.Interface.load(name="spaces/sanchit-gandhi/whisper-large-v2")
 
10
  import os
11
- os.system('apt install chromium-chromedriver')
12
- os.system('cp /usr/lib/chromium-browser/chromedriver /usr/bin')
13
  session_token = os.environ.get('SessionToken')
14
  conversation_id = os.environ.get('conversation_id')
15
  # ChatGPT
16
  from revChatGPT.ChatGPT import Chatbot
17
- chatbot = Chatbot({
18
- "session_token": session_token}) # You can start a custom conversation
19
 
20
  title = "Speech to ChatGPT to Speech"
21
  #info = "more info at [Neon Coqui TTS Plugin](https://github.com/NeonGeckoCom/neon-tts-plugin-coqui), [Coqui TTS](https://github.com/coqui-ai/TTS)"
@@ -27,8 +25,9 @@ coquiTTS = CoquiTTS()
27
 
28
  # ChatGPT
29
  def chat_hf(audio, custom_token, language):
30
- #output = chatgpt(audio, "transcribe", fn_index=0)
31
- #whisper_text, gpt_response = output[0], output[1]
 
32
  try:
33
  whisper_text = translate(audio)
34
  if whisper_text == "ERROR: You have to either use the microphone or upload an audio file":
@@ -54,7 +53,7 @@ def chat_hf(audio, custom_token, language):
54
  #api.refresh_auth() # refresh the authorization token
55
  #api.reset_conversation() # reset the conversation
56
  #gpt_response = resp['message']
57
-
58
  # to voice
59
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
60
  coquiTTS.get_tts(gpt_response, fp, speaker = {"language" : language})
 
7
  #import whisper
8
  #whisper_model = whisper.load_model("small")
9
  whisper = gr.Interface.load(name="spaces/sanchit-gandhi/whisper-large-v2")
10
+ chatgpt = gr.Blocks.load(name="fffiloni/whisper-to-chatGPT")
11
  import os
 
 
12
  session_token = os.environ.get('SessionToken')
13
  conversation_id = os.environ.get('conversation_id')
14
  # ChatGPT
15
  from revChatGPT.ChatGPT import Chatbot
16
+ #chatbot = Chatbot({"session_token": session_token}) # You can start a custom conversation
 
17
 
18
  title = "Speech to ChatGPT to Speech"
19
  #info = "more info at [Neon Coqui TTS Plugin](https://github.com/NeonGeckoCom/neon-tts-plugin-coqui), [Coqui TTS](https://github.com/coqui-ai/TTS)"
 
25
 
26
  # ChatGPT
27
  def chat_hf(audio, custom_token, language):
28
+ output = chatgpt(audio, "transcribe", fn_index=0)
29
+ whisper_text, gpt_response = output[0], output[1]
30
+ '''
31
  try:
32
  whisper_text = translate(audio)
33
  if whisper_text == "ERROR: You have to either use the microphone or upload an audio file":
 
53
  #api.refresh_auth() # refresh the authorization token
54
  #api.reset_conversation() # reset the conversation
55
  #gpt_response = resp['message']
56
+ '''
57
  # to voice
58
  with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
59
  coquiTTS.get_tts(gpt_response, fp, speaker = {"language" : language})