Firefly777a commited on
Commit
8bdb719
·
1 Parent(s): 2cc8a36

Large modification to the prompt, added rules.

Browse files
Files changed (1) hide show
  1. app.py +22 -28
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 = """The following is an incomplete transcript of a brief conversation.
62
- Predict the next few words int he transcript to complete the sentence.
63
- A few examples of transcripts and predictions are provided below:
64
- Transcript: Tomorrow night we're going out to
65
- Prediction: The Movies, A Restaurant, A Baseball Game, The Theater, A Party for a friend
66
- Transcript: I would like to order a cheeseburger with a side of
67
- Prediction: Frnech fries, Milkshake, Apple slices, Side salad, Extra katsup
68
- Transcript: My friend Savanah is
69
- Prediction: An elecrical engineer, A marine biologist, A classical musician
70
- Transcript: I need to buy a birthday
71
- Prediction: Present, Gift, Cake, Card
72
- Given these examples, predict the next few words in the following sentence:
 
 
 
 
 
 
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
- fn=inference,
113
- inputs=[
114
- gr.inputs.Audio(source="microphone", type="filepath"),
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