Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,22 @@
|
|
1 |
import whisper
|
2 |
import gradio as gr
|
|
|
|
|
|
|
3 |
|
4 |
# load model and processor
|
5 |
|
6 |
model = whisper.load_model("medium")
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def transcribe(audio):
|
10 |
|
@@ -26,7 +38,24 @@ def transcribe(audio):
|
|
26 |
return result.text
|
27 |
|
28 |
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
# gr.Interface(
|
31 |
# title = 'Talk to NP',
|
32 |
# fn=transcribe,
|
@@ -59,7 +88,7 @@ with demo:
|
|
59 |
b2 = gr.Button("Summarize")
|
60 |
|
61 |
b1.click(transcribe, inputs=audio_file, outputs=text1)
|
62 |
-
b2.click(
|
63 |
|
64 |
demo.launch()
|
65 |
|
|
|
1 |
import whisper
|
2 |
import gradio as gr
|
3 |
+
import openai
|
4 |
+
import os
|
5 |
+
openai.api_key = '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'
|
6 |
|
7 |
# load model and processor
|
8 |
|
9 |
model = whisper.load_model("medium")
|
10 |
|
11 |
+
def get_completion(prompt, model='gpt-3.5-turbo'):
|
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 |
return result.text
|
39 |
|
40 |
|
41 |
+
prompt = f"""
|
42 |
+
You are a world class nurse practitioner. You are provided with text delimited by triple quotes. \
|
43 |
+
Summarize the text and put it in a table format with rows as follows: \
|
44 |
+
|
45 |
+
1. Patient identification:
|
46 |
+
2. Chief complaint:
|
47 |
+
3. Medical history:
|
48 |
+
4. Family history:
|
49 |
+
5. Social history:
|
50 |
+
6. Review of systems:
|
51 |
+
7. Current medications:
|
52 |
+
8. Vaccination status:
|
53 |
+
9. Emotional well-being:
|
54 |
+
10. Patient concerns and expectations:
|
55 |
+
|
56 |
+
\"\"\"{text_1}\"\"\"
|
57 |
+
"""
|
58 |
+
|
59 |
# gr.Interface(
|
60 |
# title = 'Talk to NP',
|
61 |
# fn=transcribe,
|
|
|
88 |
b2 = gr.Button("Summarize")
|
89 |
|
90 |
b1.click(transcribe, inputs=audio_file, outputs=text1)
|
91 |
+
b2.click(get_completion, inputs=text1, outputs=text2)
|
92 |
|
93 |
demo.launch()
|
94 |
|