JonnoMason commited on
Commit
3d17bcf
1 Parent(s): 9b8008e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -1
app.py CHANGED
@@ -1,3 +1,37 @@
1
  import gradio as gr
 
 
2
 
3
- gr.load("models/luigisaetta/whisper-atcosim3").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import pandas as pd
3
+ import io
4
 
5
+ # Load the model
6
+ model = gr.load("models/luigisaetta/whisper-atcosim3")
7
+
8
+ # Function to process the model output and convert to CSV
9
+ def process_output(audio):
10
+ # Get the transcription from the model
11
+ transcription = model(audio)
12
+
13
+ # Assuming the transcription includes timestamps in some way
14
+ # If not, you would need to generate timestamps (this depends on your model's output format)
15
+ # Here, we assume the transcription is a list of dictionaries with 'start', 'end', and 'text'
16
+
17
+ # Convert the transcription to a DataFrame
18
+ df = pd.DataFrame(transcription)
19
+
20
+ # Create a CSV file in memory
21
+ csv_buffer = io.StringIO()
22
+ df.to_csv(csv_buffer, index=False)
23
+ csv_buffer.seek(0)
24
+
25
+ return csv_buffer.getvalue()
26
+
27
+ # Create the Gradio interface
28
+ iface = gr.Interface(
29
+ fn=process_output,
30
+ inputs=gr.Audio(source="microphone", type="file"),
31
+ outputs="file",
32
+ title="Audio Transcription to CSV",
33
+ description="Upload an audio file and get the transcription in a CSV format with timestamps."
34
+ )
35
+
36
+ # Launch the app
37
+ iface.launch()