Spaces:
Running
Running
Commit
·
8bdb719
1
Parent(s):
2cc8a36
Large modification to the prompt, added rules.
Browse files
app.py
CHANGED
@@ -38,10 +38,6 @@ model = whisper.load_model("tiny")
|
|
38 |
|
39 |
|
40 |
def inference(audio, state=""):
|
41 |
-
|
42 |
-
#time.sleep(2)
|
43 |
-
#text = p(audio)["text"]
|
44 |
-
#state += text + " "
|
45 |
# load audio data
|
46 |
audio = whisper.load_audio(audio)
|
47 |
# ensure sample is in correct format for inference
|
@@ -58,20 +54,26 @@ def inference(audio, state=""):
|
|
58 |
result = whisper.decode(model, mel, options)
|
59 |
print("result pre gp model from whisper: ", result, ".text ", result.text, "and the data type: ", type(result.text))
|
60 |
|
61 |
-
PROMPT = """
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
"""
|
74 |
-
text = PROMPT + result.text
|
75 |
|
76 |
openai.api_key = os.environ["Openai_APIkey"]
|
77 |
|
@@ -107,17 +109,9 @@ def inference(audio, state=""):
|
|
107 |
|
108 |
|
109 |
# get audio from microphone
|
110 |
-
|
111 |
gr.Interface(
|
112 |
-
|
113 |
-
inputs=[
|
114 |
-
|
115 |
-
"state"
|
116 |
-
],
|
117 |
-
outputs=[
|
118 |
-
"textbox",
|
119 |
-
"state",
|
120 |
-
"textbox"
|
121 |
-
],
|
122 |
live=True).launch()
|
123 |
|
|
|
38 |
|
39 |
|
40 |
def inference(audio, state=""):
|
|
|
|
|
|
|
|
|
41 |
# load audio data
|
42 |
audio = whisper.load_audio(audio)
|
43 |
# ensure sample is in correct format for inference
|
|
|
54 |
result = whisper.decode(model, mel, options)
|
55 |
print("result pre gp model from whisper: ", result, ".text ", result.text, "and the data type: ", type(result.text))
|
56 |
|
57 |
+
PROMPT = """This is a tool for helping someone with memory issues remember the next word.
|
58 |
+
|
59 |
+
The predictions follow a few rules:
|
60 |
+
1) The predictions are suggestions of ways to continue the transcript as if someone forgot what the next word was.
|
61 |
+
2) The predictions do not repeat themselves.
|
62 |
+
3) The predictions focus on suggesting nouns, adjectives, and verbs.
|
63 |
+
4) The predictions are related to the context in the transcript.
|
64 |
+
|
65 |
+
EXAMPLES:
|
66 |
+
Transcript: Tomorrow night we're going out to
|
67 |
+
Prediction: The Movies, A Restaurant, A Baseball Game, The Theater, A Party for a friend
|
68 |
+
Transcript: I would like to order a cheeseburger with a side of
|
69 |
+
Prediction: Frnech fries, Milkshake, Apple slices, Side salad, Extra katsup
|
70 |
+
Transcript: My friend Savanah is
|
71 |
+
Prediction: An elecrical engineer, A marine biologist, A classical musician
|
72 |
+
Transcript: I need to buy a birthday
|
73 |
+
Prediction: Present, Gift, Cake, Card
|
74 |
+
Transcript:
|
75 |
"""
|
76 |
+
text = PROMPT + result.text + "\nPrediction: "
|
77 |
|
78 |
openai.api_key = os.environ["Openai_APIkey"]
|
79 |
|
|
|
109 |
|
110 |
|
111 |
# get audio from microphone
|
|
|
112 |
gr.Interface(
|
113 |
+
fn=inference,
|
114 |
+
inputs=[gr.inputs.Audio(source="microphone", type="filepath"), "state"],
|
115 |
+
outputs=["textbox","state","textbox"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
live=True).launch()
|
117 |
|