Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -29,12 +29,8 @@ from encoder import inference as encoder
|
|
29 |
from vocoder.hifigan import inference as gan_vocoder
|
30 |
from synthesizer.inference import Synthesizer
|
31 |
|
32 |
-
|
33 |
-
{"role": "system", "content": "You are
|
34 |
-
]
|
35 |
-
|
36 |
-
mes3 = [
|
37 |
-
{"role": "system", "content": "You are my personal assistant. Respond to me only in Chinese. Your name is Alice."}
|
38 |
]
|
39 |
|
40 |
res = []
|
@@ -80,7 +76,7 @@ class Mandarin:
|
|
80 |
|
81 |
return wav, sample_rate
|
82 |
|
83 |
-
def greet(apikey, upload, audio
|
84 |
|
85 |
openai.api_key = apikey
|
86 |
|
@@ -100,10 +96,7 @@ def greet(apikey, upload, audio, choice1):
|
|
100 |
result = whisper.decode(model, mel, options)
|
101 |
res.append(result.text)
|
102 |
|
103 |
-
|
104 |
-
messages = mes2
|
105 |
-
elif choice1 == "Alice":
|
106 |
-
messages = mes3
|
107 |
|
108 |
# chatgpt
|
109 |
n = len(res)
|
@@ -148,10 +141,9 @@ def greet(apikey, upload, audio, choice1):
|
|
148 |
c1=gr.Interface(
|
149 |
fn=greet,
|
150 |
inputs=[
|
151 |
-
gr.Textbox(lines=1, label = "请填写您的OpenAI-API-key"),
|
152 |
gr.Audio(source="upload", label = "请上传您喜欢的声音(wav文件)", type="filepath"),
|
153 |
gr.Audio(source="microphone", label = "和您的专属AI聊天吧!", type="filepath"),
|
154 |
-
gr.Radio(["Therapist", "Alice"], label="Therapist Tina or Assistant Alice?"),
|
155 |
],
|
156 |
outputs=[
|
157 |
gr.Textbox(label="Speech to Text"), gr.Textbox(label="ChatGPT Output"), gr.Audio(label="Audio with Custom Voice"),
|
@@ -165,10 +157,9 @@ c1=gr.Interface(
|
|
165 |
c2=gr.Interface(
|
166 |
fn=greet,
|
167 |
inputs=[
|
168 |
-
gr.Textbox(lines=1, label = "请填写您的OpenAI-API-key"),
|
169 |
gr.Audio(source="microphone", label = "请上传您喜欢的声音,并尽量避免噪音", type="filepath"),
|
170 |
gr.Audio(source="microphone", label = "和您的专属AI聊天吧!", type="filepath"),
|
171 |
-
gr.Radio(["Therapist", "Alice"], label="Therapist Tina or Assistant Alice?"),
|
172 |
],
|
173 |
outputs=[
|
174 |
gr.Textbox(label="Speech to Text"), gr.Textbox(label="ChatGPT Output"), gr.Audio(label="Audio with Custom Voice"),
|
|
|
29 |
from vocoder.hifigan import inference as gan_vocoder
|
30 |
from synthesizer.inference import Synthesizer
|
31 |
|
32 |
+
mes = [
|
33 |
+
{"role": "system", "content": "You are my personal assistant. Respond to me only in Chinese."}
|
|
|
|
|
|
|
|
|
34 |
]
|
35 |
|
36 |
res = []
|
|
|
76 |
|
77 |
return wav, sample_rate
|
78 |
|
79 |
+
def greet(apikey, upload, audio):
|
80 |
|
81 |
openai.api_key = apikey
|
82 |
|
|
|
96 |
result = whisper.decode(model, mel, options)
|
97 |
res.append(result.text)
|
98 |
|
99 |
+
messages = mes
|
|
|
|
|
|
|
100 |
|
101 |
# chatgpt
|
102 |
n = len(res)
|
|
|
141 |
c1=gr.Interface(
|
142 |
fn=greet,
|
143 |
inputs=[
|
144 |
+
gr.Textbox(lines=1, label = "请填写您的OpenAI-API-key", type = "password"),
|
145 |
gr.Audio(source="upload", label = "请上传您喜欢的声音(wav文件)", type="filepath"),
|
146 |
gr.Audio(source="microphone", label = "和您的专属AI聊天吧!", type="filepath"),
|
|
|
147 |
],
|
148 |
outputs=[
|
149 |
gr.Textbox(label="Speech to Text"), gr.Textbox(label="ChatGPT Output"), gr.Audio(label="Audio with Custom Voice"),
|
|
|
157 |
c2=gr.Interface(
|
158 |
fn=greet,
|
159 |
inputs=[
|
160 |
+
gr.Textbox(lines=1, label = "请填写您的OpenAI-API-key", type = "password"),
|
161 |
gr.Audio(source="microphone", label = "请上传您喜欢的声音,并尽量避免噪音", type="filepath"),
|
162 |
gr.Audio(source="microphone", label = "和您的专属AI聊天吧!", type="filepath"),
|
|
|
163 |
],
|
164 |
outputs=[
|
165 |
gr.Textbox(label="Speech to Text"), gr.Textbox(label="ChatGPT Output"), gr.Audio(label="Audio with Custom Voice"),
|