jpdiazpardo commited on
Commit
bba23d3
1 Parent(s): d52a468

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import torch
3
  from charts import spider_chart
 
4
  from icon import generate_icon
5
  from transformers import pipeline
6
  from timestamp import format_timestamp
@@ -29,7 +30,7 @@ def transcribe(file, task, return_timestamps):
29
  if return_timestamps==True:
30
  spider_text = [f"{chunk['text']}" for chunk in timestamps] #Text for spider chart without timestamps
31
  timestamps = [f"[{format_timestamp(chunk['timestamp'][0])} -> {format_timestamp(chunk['timestamp'][1])}] {chunk['text']}" for chunk in timestamps]
32
-
33
  else:
34
  timestamps = [f"{chunk['text']}" for chunk in timestamps]
35
  spider_text = timestamps
@@ -38,8 +39,9 @@ def transcribe(file, task, return_timestamps):
38
  text = f"<h4>Transcription</h4><div style='overflow-y: scroll; height: 250px;'>{text}</div>"
39
 
40
  spider_text = "\n".join(str(feature) for feature in spider_text)
41
- fig = spider_chart(classifier, spider_text)
42
 
 
 
43
  return file, text, fig
44
 
45
 
@@ -74,7 +76,7 @@ article = ("<div style='text-align: center; max-width:800px; margin:10px auto;'>
74
 
75
  title = "Scream: Fine-Tuned Whisper model for automatic gutural speech recognition 🤟🤟🤟"
76
 
77
- demo = gr.Interface(title = title, fn=transcribe, inputs = inputs, outputs = outputs, description=description, cache_examples=True, allow_flagging="never", article = article , examples=None)#examples)
78
 
79
  demo.queue(concurrency_count=3)
80
  demo.launch(debug = True)
 
1
  import gradio as gr
2
  import torch
3
  from charts import spider_chart
4
+ from dictionaries import calculate_average, transform_dict
5
  from icon import generate_icon
6
  from transformers import pipeline
7
  from timestamp import format_timestamp
 
30
  if return_timestamps==True:
31
  spider_text = [f"{chunk['text']}" for chunk in timestamps] #Text for spider chart without timestamps
32
  timestamps = [f"[{format_timestamp(chunk['timestamp'][0])} -> {format_timestamp(chunk['timestamp'][1])}] {chunk['text']}" for chunk in timestamps]
33
+
34
  else:
35
  timestamps = [f"{chunk['text']}" for chunk in timestamps]
36
  spider_text = timestamps
 
39
  text = f"<h4>Transcription</h4><div style='overflow-y: scroll; height: 250px;'>{text}</div>"
40
 
41
  spider_text = "\n".join(str(feature) for feature in spider_text)
 
42
 
43
+ fig = spider_chart(calculate_average([transform_dict(classifier.predict(t)[0]) for t in spider_text.split("\n")]))
44
+
45
  return file, text, fig
46
 
47
 
 
76
 
77
  title = "Scream: Fine-Tuned Whisper model for automatic gutural speech recognition 🤟🤟🤟"
78
 
79
+ demo = gr.Interface(title = title, fn=transcribe, inputs = inputs, outputs = outputs, description=description, cache_examples=True, allow_flagging="never", article = article , examples=examples)
80
 
81
  demo.queue(concurrency_count=3)
82
  demo.launch(debug = True)