Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,19 +4,10 @@ import openai
|
|
4 |
import os
|
5 |
openai.api_key = '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'
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
model = whisper.load_model("medium")
|
10 |
|
11 |
-
|
12 |
-
messages = [{"role": "user", "content": prompt}]
|
13 |
-
response = openai.ChatCompletion.create(
|
14 |
-
model = model,
|
15 |
-
messages = messages,
|
16 |
-
temperature = 0,
|
17 |
-
|
18 |
-
)
|
19 |
-
return response.choices[0].message['content']
|
20 |
|
21 |
def transcribe(audio):
|
22 |
|
@@ -38,51 +29,14 @@ def transcribe(audio):
|
|
38 |
return result.text
|
39 |
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
demo = gr.Blocks()
|
56 |
-
|
57 |
-
with demo:
|
58 |
-
audio_file = gr.Audio(type="filepath")
|
59 |
-
text1 = gr.Textbox()
|
60 |
-
text2 = gr.Textbox()
|
61 |
-
|
62 |
-
prompt = f"""
|
63 |
-
You are a world class nurse practitioner. You are provided with text delimited by triple quotes. \
|
64 |
-
Summarize the text and put it in a table format with rows as follows: \
|
65 |
-
|
66 |
-
1. Patient identification:
|
67 |
-
2. Chief complaint:
|
68 |
-
3. Medical history:
|
69 |
-
4. Family history:
|
70 |
-
5. Social history:
|
71 |
-
6. Review of systems:
|
72 |
-
7. Current medications:
|
73 |
-
8. Vaccination status:
|
74 |
-
9. Emotional well-being:
|
75 |
-
10. Patient concerns and expectations:
|
76 |
-
|
77 |
-
\"\"\"{text1}\"\"\"
|
78 |
-
"""
|
79 |
-
|
80 |
-
b1 = gr.Button("Transcribe audio")
|
81 |
-
b2 = gr.Button("Summarize")
|
82 |
-
|
83 |
-
b1.click(transcribe, inputs=audio_file, outputs=text1)
|
84 |
-
b2.click(get_completion, inputs=text1, outputs=text2)
|
85 |
-
|
86 |
-
|
87 |
-
demo.launch()
|
88 |
-
|
|
|
4 |
import os
|
5 |
openai.api_key = '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'
|
6 |
|
7 |
+
import whisper
|
8 |
+
import gradio as gr
|
|
|
9 |
|
10 |
+
model = whisper.load_model("small")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
def transcribe(audio):
|
13 |
|
|
|
29 |
return result.text
|
30 |
|
31 |
|
32 |
+
|
33 |
+
gr.Interface(
|
34 |
+
title = 'OpenAI Whisper ASR Gradio Web UI',
|
35 |
+
fn=transcribe,
|
36 |
+
inputs=[
|
37 |
+
gr.inputs.Audio(source="microphone", type="filepath")
|
38 |
+
],
|
39 |
+
outputs=[
|
40 |
+
"textbox"
|
41 |
+
],
|
42 |
+
live=True).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|