chibop commited on
Commit
424d21c
·
verified ·
1 Parent(s): f8e9ce0

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. chat.py +4 -3
  2. requirements.txt +2 -1
chat.py CHANGED
@@ -5,6 +5,8 @@ import gradio as gr
5
  import codecs
6
  import base64
7
  import json
 
 
8
 
9
  def login(username, password):
10
  users = json.loads(os.environ.get('users'))
@@ -59,9 +61,8 @@ def transcribe(file):
59
  def speak(history):
60
  text = history[-1][1]
61
  speech = client.audio.speech.create(model="tts-1", voice="alloy", input=text)
62
- audio = base64.b64encode(speech.read()).decode("utf-8")
63
- src = f"data:audio/mpeg;base64,{audio}"
64
- return src
65
 
66
  def vote(data: gr.LikeData):
67
  if data.liked:
 
5
  import codecs
6
  import base64
7
  import json
8
+ import soundfile as sf
9
+ from io import BytesIO
10
 
11
  def login(username, password):
12
  users = json.loads(os.environ.get('users'))
 
61
  def speak(history):
62
  text = history[-1][1]
63
  speech = client.audio.speech.create(model="tts-1", voice="alloy", input=text)
64
+ data, sr = sf.read(BytesIO(speech.read()))
65
+ return sr, data
 
66
 
67
  def vote(data: gr.LikeData):
68
  if data.liked:
requirements.txt CHANGED
@@ -1 +1,2 @@
1
- openai
 
 
1
+ openai
2
+ soundfile