JohnsonManuel commited on
Commit
0f77e5c
1 Parent(s): 786be1f

Initial Commit - Added all files needed

Browse files
Files changed (2) hide show
  1. app.py +37 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import whisper
2
+ import gradio as gr
3
+ import datetime
4
+
5
+ model = whisper.load_model('base')
6
+
7
+
8
+
9
+ def transcribe(inputs , timestamp):
10
+ if inputs is None:
11
+ raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.")
12
+ output = ""
13
+ result = model.transcribe(inputs)
14
+ if timestamp == "Yes":
15
+ for indx, segment in enumerate(result['segments']):
16
+ output += str(datetime.timedelta (seconds=segment['start'])) +" "+ str(datetime.timedelta (seconds=segment['end'])) + "\n"
17
+ output += segment['text'].strip() + '\n'
18
+ else:
19
+ output = result["text"]
20
+
21
+ return output
22
+
23
+
24
+
25
+
26
+ interface = gr.Interface(
27
+ fn=transcribe,
28
+ inputs=[gr.Audio(sources=["upload"],type="filepath"),
29
+ gr.Radio(["Yes", "No"], label="Timestamp", info="Displays with timestamp if needed."),],
30
+ outputs="text",
31
+ title="Whisper Large V3: Transcribe Audio",
32
+ description=(
33
+ "Transcribe long-form microphone or audio inputs with the click of a button! Demo uses the OpenAI Whisper API"
34
+ )
35
+ )
36
+
37
+ interface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio==4.36.1
2
+ openai-whisper==20231117
3
+ numpy