Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,10 +5,15 @@ import pytube as pt
|
|
5 |
pipe = pipeline(model="Hoft/whisper-small-swedish-asr") # change to "your-username/the-name-you-picked"
|
6 |
sa = pipeline('sentiment-analysis', model='marma/bert-base-swedish-cased-sentiment')
|
7 |
|
|
|
|
|
|
|
|
|
|
|
8 |
def microphone_or_file_transcribe(audio):
|
9 |
text = pipe(audio)["text"]
|
10 |
sa_result = sa(text)[0]
|
11 |
-
return text, sa_result['label']
|
12 |
|
13 |
def youtube_transcribe(url):
|
14 |
yt = pt.YouTube(url)
|
@@ -18,7 +23,8 @@ def youtube_transcribe(url):
|
|
18 |
|
19 |
text = pipe("audio.mp3")["text"]
|
20 |
|
21 |
-
|
|
|
22 |
|
23 |
|
24 |
app = gr.Blocks()
|
|
|
5 |
pipe = pipeline(model="Hoft/whisper-small-swedish-asr") # change to "your-username/the-name-you-picked"
|
6 |
sa = pipeline('sentiment-analysis', model='marma/bert-base-swedish-cased-sentiment')
|
7 |
|
8 |
+
def get_emoji(feeling):
|
9 |
+
if feeling == 'POSITIVE':
|
10 |
+
return 'π'
|
11 |
+
else:
|
12 |
+
return 'π'
|
13 |
def microphone_or_file_transcribe(audio):
|
14 |
text = pipe(audio)["text"]
|
15 |
sa_result = sa(text)[0]
|
16 |
+
return text, get_emoji(sa_result['label'])
|
17 |
|
18 |
def youtube_transcribe(url):
|
19 |
yt = pt.YouTube(url)
|
|
|
23 |
|
24 |
text = pipe("audio.mp3")["text"]
|
25 |
|
26 |
+
sa_result = sa(text)[0]
|
27 |
+
return text, get_emoji(sa_result['label'])
|
28 |
|
29 |
|
30 |
app = gr.Blocks()
|