ysharma HF staff commited on
Commit
5b5d4af
1 Parent(s): 72e4eb6
Files changed (1) hide show
  1. app.py +42 -0
app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import numpy as np
3
+
4
+ #try:
5
+ # import tensorflow # required in Colab to avoid protobuf compatibility issues
6
+ #except ImportError:
7
+ # pass
8
+
9
+ #import torch
10
+ #import pandas as pd
11
+ import whisper
12
+ #import torchaudio
13
+
14
+ #from tqdm.notebook import tqdm
15
+
16
+
17
+ #DEVICE = "cuda" if torch.cuda.is_available() else "CPU"
18
+ model = whisper.load_model("base.en")
19
+
20
+ def fun(audio):
21
+ result = model.transcribe(audio)
22
+ return result["text"]
23
+
24
+ # predict without timestamps for short-form transcription
25
+ #options = whisper.DecodingOptions(language="en", without_timestamps=True)
26
+
27
+
28
+ #for mels, texts in tqdm(loader):
29
+ # results = model.decode(mels, options)
30
+ # hypotheses.extend([result.text for result in results])
31
+ # references.extend(texts)
32
+
33
+ gr.Interface(
34
+ title = 'Testing Whisper',
35
+ fn=fun,
36
+ inputs=[
37
+ gr.inputs.Audio(source="microphone", streaming = "True" ) #,type="filepath")
38
+ ],
39
+ outputs=[
40
+ "textbox"
41
+ ],
42
+ live=True).launch()