Spaces:
Runtime error
Runtime error
[Enhancement] Add waveform output (#5)
Browse files- [Enhancement] Add waveform output (2d3ebd5088c5a51c240b5bbcfd9bbc210aac98ca)
Co-authored-by: Jahangir <[email protected]>
app.py
CHANGED
@@ -12,6 +12,7 @@ import json
|
|
12 |
import os
|
13 |
import re
|
14 |
import os
|
|
|
15 |
|
16 |
import pandas as pd
|
17 |
|
@@ -51,7 +52,6 @@ df_init = pd.DataFrame(columns=['Task', 'Top 1', 'Top 2', 'Top 3', 'Top 4', 'Top
|
|
51 |
transcription_df = gr.DataFrame(value=df_init, label="Model Results", row_count=(
|
52 |
0, "dynamic"), max_rows=30, wrap=True, overflow_row_behaviour='paginate')
|
53 |
# outputs = [gr.components.Textbox()]
|
54 |
-
outputs = transcription_df
|
55 |
|
56 |
df_init_live = pd.DataFrame(columns=['Task', 'Top 1', 'Top 2', 'Top 3', 'Top 4', 'Top 5'])
|
57 |
transcription_df_live = gr.DataFrame(value=df_init_live, label="Model Results", row_count=(
|
@@ -187,11 +187,22 @@ def model_infernce(inputs):
|
|
187 |
df = pd.DataFrame(df_objects, columns=['Task', 'Top 1', 'Top 2', 'Top 3', 'Top 4', 'Top 5'])
|
188 |
return df
|
189 |
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
|
196 |
def live_convert_audio(microphone):
|
197 |
if (microphone is not None):
|
@@ -199,6 +210,8 @@ def live_convert_audio(microphone):
|
|
199 |
df = model_infernce(inputs)
|
200 |
return df
|
201 |
|
|
|
|
|
202 |
audio_chunked = gr.Interface(
|
203 |
fn=convert_audio,
|
204 |
inputs=inputs,
|
|
|
12 |
import os
|
13 |
import re
|
14 |
import os
|
15 |
+
import random
|
16 |
|
17 |
import pandas as pd
|
18 |
|
|
|
52 |
transcription_df = gr.DataFrame(value=df_init, label="Model Results", row_count=(
|
53 |
0, "dynamic"), max_rows=30, wrap=True, overflow_row_behaviour='paginate')
|
54 |
# outputs = [gr.components.Textbox()]
|
|
|
55 |
|
56 |
df_init_live = pd.DataFrame(columns=['Task', 'Top 1', 'Top 2', 'Top 3', 'Top 4', 'Top 5'])
|
57 |
transcription_df_live = gr.DataFrame(value=df_init_live, label="Model Results", row_count=(
|
|
|
187 |
df = pd.DataFrame(df_objects, columns=['Task', 'Top 1', 'Top 2', 'Top 3', 'Top 4', 'Top 5'])
|
188 |
return df
|
189 |
|
190 |
+
COLORS = [
|
191 |
+
["#ff0000", "#00ff00"],
|
192 |
+
["#00ff00", "#0000ff"],
|
193 |
+
["#0000ff", "#ff0000"],
|
194 |
+
]
|
195 |
+
|
196 |
+
def convert_audio(audio):
|
197 |
+
df = model_infernce(audio)
|
198 |
+
waveform = gr.make_waveform(audio,
|
199 |
+
bars_color=random.choice(COLORS),
|
200 |
+
bar_count=80,
|
201 |
+
bar_width=0.4)
|
202 |
+
return df, waveform
|
203 |
+
|
204 |
+
def audio_waveform(audio):
|
205 |
+
return gr.make_waveform(audio)
|
206 |
|
207 |
def live_convert_audio(microphone):
|
208 |
if (microphone is not None):
|
|
|
210 |
df = model_infernce(inputs)
|
211 |
return df
|
212 |
|
213 |
+
outputs = [transcription_df, gr.Video(label="Waveform")]
|
214 |
+
|
215 |
audio_chunked = gr.Interface(
|
216 |
fn=convert_audio,
|
217 |
inputs=inputs,
|