Spaces:
Runtime error
Runtime error
Hugo Lindgren commited on
Commit ·
77d117e
1
Parent(s): c152203
asd
Browse files
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🐠
|
|
| 4 |
colorFrom: gray
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
|
|
|
| 4 |
colorFrom: gray
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.7.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: apache-2.0
|
app.py
CHANGED
|
@@ -19,15 +19,13 @@ pipe = pipeline(model="Siphh/wablab2")
|
|
| 19 |
psychologist_url = "https://raw.githubusercontent.com/rogoran/id2223kth.github.io/master/src/serverless-ml-intro/serverless-ml-lab/wine_images/360_F_169387942_tUJn9ADX31sRDFCuK9nlBuRR4gO6a1TK.jpg"
|
| 20 |
IMG = Image.open(requests.get(psychologist_url, stream=True).raw)
|
| 21 |
latest_messages = [{"role": "system", "content": "Du är en svensktalande psykolog."}]
|
| 22 |
-
|
| 23 |
|
| 24 |
def transcribe(audio):
|
| 25 |
if audio is None or audio == "":
|
| 26 |
return
|
| 27 |
-
text = pipe(audio)
|
| 28 |
-
|
| 29 |
-
return
|
| 30 |
-
return chat(text)
|
| 31 |
|
| 32 |
|
| 33 |
def chat(prompt):
|
|
@@ -45,9 +43,10 @@ with gr.Blocks() as demo:
|
|
| 45 |
with gr.Column():
|
| 46 |
inp = gr.Audio(sources="microphone", type="filepath")
|
| 47 |
btn = gr.Button("Send transcribed msg")
|
|
|
|
| 48 |
with gr.Column():
|
| 49 |
gr.Image(value=IMG, label="Doctor Amanda")
|
| 50 |
out = gr.Textbox(label="Doctor Amandas answers")
|
| 51 |
-
btn.click(fn=transcribe, inputs=inp, outputs=out)
|
| 52 |
|
| 53 |
demo.launch()
|
|
|
|
| 19 |
psychologist_url = "https://raw.githubusercontent.com/rogoran/id2223kth.github.io/master/src/serverless-ml-intro/serverless-ml-lab/wine_images/360_F_169387942_tUJn9ADX31sRDFCuK9nlBuRR4gO6a1TK.jpg"
|
| 20 |
IMG = Image.open(requests.get(psychologist_url, stream=True).raw)
|
| 21 |
latest_messages = [{"role": "system", "content": "Du är en svensktalande psykolog."}]
|
| 22 |
+
text = ""
|
| 23 |
|
| 24 |
def transcribe(audio):
|
| 25 |
if audio is None or audio == "":
|
| 26 |
return
|
| 27 |
+
text = pipe(audio)["text"]
|
| 28 |
+
return chat(text), text
|
|
|
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
def chat(prompt):
|
|
|
|
| 43 |
with gr.Column():
|
| 44 |
inp = gr.Audio(sources="microphone", type="filepath")
|
| 45 |
btn = gr.Button("Send transcribed msg")
|
| 46 |
+
transcr_text = gr.Textbox(label="Din senaste fråga")
|
| 47 |
with gr.Column():
|
| 48 |
gr.Image(value=IMG, label="Doctor Amanda")
|
| 49 |
out = gr.Textbox(label="Doctor Amandas answers")
|
| 50 |
+
btn.click(fn=transcribe, inputs=inp, outputs=[out, transcr_text])
|
| 51 |
|
| 52 |
demo.launch()
|