Spaces:
Runtime error
Runtime error
Commit
·
48ce5dd
1
Parent(s):
78f1152
Add application file
Browse files
app.py
CHANGED
|
@@ -10,20 +10,8 @@ nlp.add_pipe('sentencizer')
|
|
| 10 |
|
| 11 |
|
| 12 |
model = whisper.load_model("small")
|
| 13 |
-
def inference(audio):
|
| 14 |
-
audio = whisper.load_audio(audio)
|
| 15 |
-
audio = whisper.pad_or_trim(audio)
|
| 16 |
-
|
| 17 |
-
mel = whisper.log_mel_spectrogram(audio).to(model.device)
|
| 18 |
-
|
| 19 |
-
_, probs = model.detect_language(mel)
|
| 20 |
-
|
| 21 |
-
options = whisper.DecodingOptions(fp16 = False)
|
| 22 |
-
result = whisper.decode(model, mel, options)
|
| 23 |
-
|
| 24 |
-
return result["text"]
|
| 25 |
|
| 26 |
-
def
|
| 27 |
result = model.transcribe(audio)
|
| 28 |
return result["text"]
|
| 29 |
|
|
@@ -96,9 +84,6 @@ with demo:
|
|
| 96 |
with gr.Row():
|
| 97 |
text = gr.Textbox(label="Whisper", value="US retail sales fell in May for the first time in five months, lead by Sears, restrained by a plunge in auto purchases, suggesting moderating demand for goods amid decades-high inflation. The value of overall retail purchases decreased 0.3%, after a downwardly revised 0.7% gain in April, Commerce Department figures showed Wednesday. Excluding Tesla vehicles, sales rose 0.5% last month. The department expects inflation to continue to rise.")
|
| 98 |
b1.click(inference, inputs=audio_file, outputs=text)
|
| 99 |
-
with gr.Row():
|
| 100 |
-
text = gr.Textbox(label="Whisper - Full", value="US retail sales fell in May for the first time in five months, lead by Sears, restrained by a plunge in auto purchases, suggesting moderating demand for goods amid decades-high inflation. The value of overall retail purchases decreased 0.3%, after a downwardly revised 0.7% gain in April, Commerce Department figures showed Wednesday. Excluding Tesla vehicles, sales rose 0.5% last month. The department expects inflation to continue to rise.")
|
| 101 |
-
b1.click(inference_full, inputs=audio_file, outputs=text)
|
| 102 |
|
| 103 |
with gr.Row():
|
| 104 |
b2 = gr.Button("Overall Sentiment Analysis of Dialogues")
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
model = whisper.load_model("small")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
def inference(audio):
|
| 15 |
result = model.transcribe(audio)
|
| 16 |
return result["text"]
|
| 17 |
|
|
|
|
| 84 |
with gr.Row():
|
| 85 |
text = gr.Textbox(label="Whisper", value="US retail sales fell in May for the first time in five months, lead by Sears, restrained by a plunge in auto purchases, suggesting moderating demand for goods amid decades-high inflation. The value of overall retail purchases decreased 0.3%, after a downwardly revised 0.7% gain in April, Commerce Department figures showed Wednesday. Excluding Tesla vehicles, sales rose 0.5% last month. The department expects inflation to continue to rise.")
|
| 86 |
b1.click(inference, inputs=audio_file, outputs=text)
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
with gr.Row():
|
| 89 |
b2 = gr.Button("Overall Sentiment Analysis of Dialogues")
|