Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,7 +14,6 @@ from transformers import AutoModelForCausalLM
|
|
| 14 |
from transformers import AutoTokenizer
|
| 15 |
import time
|
| 16 |
|
| 17 |
-
convoState = gr.State([""])
|
| 18 |
|
| 19 |
EXAMPLE_PROMPT = """This is a tool for helping someone with memory issues remember the next word.
|
| 20 |
The predictions follow a few rules:
|
|
@@ -34,11 +33,33 @@ Transcript: I need to buy a birthday
|
|
| 34 |
Prediction: Present, Gift, Cake, Card
|
| 35 |
Transcript: """
|
| 36 |
|
|
|
|
| 37 |
# whisper model specification
|
| 38 |
asr_model = whisper.load_model("tiny")
|
| 39 |
|
| 40 |
openai.api_key = os.environ["Openai_APIkey"]
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
# Transcribe function
|
| 43 |
def transcribe(audio_file):
|
| 44 |
print("Transcribing")
|
|
@@ -80,22 +101,6 @@ def inference(audio, prompt, model, temperature, latest):
|
|
| 80 |
return transcript, infers, convoState
|
| 81 |
|
| 82 |
|
| 83 |
-
|
| 84 |
-
with gr.Blocks() as face:
|
| 85 |
-
|
| 86 |
-
with gr.Row():
|
| 87 |
-
with gr.Column():
|
| 88 |
-
audio = gr.Audio(source="microphone", type="filepath")
|
| 89 |
-
promptText = gr.Textbox(lines=15, placeholder="Enter a prompt here")
|
| 90 |
-
dropChoice = gr.Dropdown(choices=["text-ada-001", "text-davinci-002", "text-davinci-003", "gpt-3.5-turbo"], label="Model")
|
| 91 |
-
sliderChoice = gr.Slider(minimum=0.0, maximum=1.0, default=0.8, step=0.1, label="Temperature")
|
| 92 |
-
transcribe_btn = gr.Button(value="Transcribe")
|
| 93 |
-
with gr.Column():
|
| 94 |
-
script = gr.Textbox(label="Transcribed text")
|
| 95 |
-
options = gr.Textbox(label="Predictions")
|
| 96 |
-
latestConvo = gr.Textbox(label="Running conversation")
|
| 97 |
-
#transcribe_btn.click(inference)
|
| 98 |
-
transcribe_btn.click(fn=inference, inputs=[audio, promptText, dropChoice, sliderChoice, convoState], outputs=[latestConvo, script, options])
|
| 99 |
-
examples = gr.Examples(examples=["Sedan, Truck, SUV", "Dalmaion, Shepherd, Lab, Mutt"], inputs=[options])
|
| 100 |
|
| 101 |
face.launch()
|
|
|
|
| 14 |
from transformers import AutoTokenizer
|
| 15 |
import time
|
| 16 |
|
|
|
|
| 17 |
|
| 18 |
EXAMPLE_PROMPT = """This is a tool for helping someone with memory issues remember the next word.
|
| 19 |
The predictions follow a few rules:
|
|
|
|
| 33 |
Prediction: Present, Gift, Cake, Card
|
| 34 |
Transcript: """
|
| 35 |
|
| 36 |
+
|
| 37 |
# whisper model specification
|
| 38 |
asr_model = whisper.load_model("tiny")
|
| 39 |
|
| 40 |
openai.api_key = os.environ["Openai_APIkey"]
|
| 41 |
|
| 42 |
+
|
| 43 |
+
# get audio from microphone
|
| 44 |
+
with gr.Blocks() as face:
|
| 45 |
+
|
| 46 |
+
with gr.Row():
|
| 47 |
+
convoState = gr.State([""])
|
| 48 |
+
with gr.Column():
|
| 49 |
+
audio = gr.Audio(source="microphone", type="filepath")
|
| 50 |
+
promptText = gr.Textbox(lines=15, placeholder="Enter a prompt here")
|
| 51 |
+
dropChoice = gr.Dropdown(choices=["text-ada-001", "text-davinci-002", "text-davinci-003", "gpt-3.5-turbo"], label="Model")
|
| 52 |
+
sliderChoice = gr.Slider(minimum=0.0, maximum=1.0, default=0.8, step=0.1, label="Temperature")
|
| 53 |
+
transcribe_btn = gr.Button(value="Transcribe")
|
| 54 |
+
with gr.Column():
|
| 55 |
+
script = gr.Textbox(label="Transcribed text")
|
| 56 |
+
options = gr.Textbox(label="Predictions")
|
| 57 |
+
latestConvo = gr.Textbox(label="Running conversation")
|
| 58 |
+
#transcribe_btn.click(inference)
|
| 59 |
+
transcribe_btn.click(fn=inference, inputs=[audio, promptText, dropChoice, sliderChoice, convoState], outputs=[latestConvo, script, options])
|
| 60 |
+
examples = gr.Examples(examples=["Sedan, Truck, SUV", "Dalmaion, Shepherd, Lab, Mutt"], inputs=[options])
|
| 61 |
+
|
| 62 |
+
|
| 63 |
# Transcribe function
|
| 64 |
def transcribe(audio_file):
|
| 65 |
print("Transcribing")
|
|
|
|
| 101 |
return transcript, infers, convoState
|
| 102 |
|
| 103 |
|
| 104 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
face.launch()
|