Spaces:
Runtime error
Runtime error
Commit
·
43ba5f1
1
Parent(s):
a7fe6bc
Update app.py
Browse files
app.py
CHANGED
@@ -48,14 +48,14 @@ title = "Scream: Fine-Tuned Whisper model for automatic gutural speech recogniti
|
|
48 |
classifier = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base", top_k=None)
|
49 |
|
50 |
#Functions-----------------------------------------------------------------------------------------------------------------------
|
51 |
-
def transcribe(
|
52 |
'''inputs: file, return_timestamps'''
|
53 |
-
outputs = pipe(
|
54 |
text = outputs["text"]
|
55 |
timestamps = outputs["chunks"]
|
56 |
|
57 |
#If return timestamps is True, return html text with timestamps format
|
58 |
-
if
|
59 |
spider_text = [f"{chunk['text']}" for chunk in timestamps] #Text for spider chart without timestamps
|
60 |
timestamps = [f"[{format_timestamp(chunk['timestamp'][0])} -> {format_timestamp(chunk['timestamp'][1])}] {chunk['text']}" for chunk in timestamps]
|
61 |
|
@@ -71,7 +71,7 @@ def transcribe(*args):#file, return_timestamps, *kwargs):
|
|
71 |
av_dict = calculate_average(trans_dict)
|
72 |
fig = spider_chart(av_dict)
|
73 |
|
74 |
-
return
|
75 |
|
76 |
embed_html = '<iframe src="https://www.youtube.com/embed/YOUTUBE_ID'\
|
77 |
'title="YouTube video player" frameborder="0" allow="accelerometer;'\
|
|
|
48 |
classifier = pipeline("text-classification", model="j-hartmann/emotion-english-distilroberta-base", top_k=None)
|
49 |
|
50 |
#Functions-----------------------------------------------------------------------------------------------------------------------
|
51 |
+
def transcribe(link,download,thumbnail,file,use_timestamps,sentiment_analysis):#file, return_timestamps, *kwargs):
|
52 |
'''inputs: file, return_timestamps'''
|
53 |
+
outputs = pipe(file, batch_size=BATCH_SIZE, generate_kwargs={"task": 'transcribe'}, return_timestamps=True)
|
54 |
text = outputs["text"]
|
55 |
timestamps = outputs["chunks"]
|
56 |
|
57 |
#If return timestamps is True, return html text with timestamps format
|
58 |
+
if use_timestamps==True:
|
59 |
spider_text = [f"{chunk['text']}" for chunk in timestamps] #Text for spider chart without timestamps
|
60 |
timestamps = [f"[{format_timestamp(chunk['timestamp'][0])} -> {format_timestamp(chunk['timestamp'][1])}] {chunk['text']}" for chunk in timestamps]
|
61 |
|
|
|
71 |
av_dict = calculate_average(trans_dict)
|
72 |
fig = spider_chart(av_dict)
|
73 |
|
74 |
+
return file, text, fig, av_dict
|
75 |
|
76 |
embed_html = '<iframe src="https://www.youtube.com/embed/YOUTUBE_ID'\
|
77 |
'title="YouTube video player" frameborder="0" allow="accelerometer;'\
|