Spaces:
Runtime error
Runtime error
add api_token
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import torch
|
|
| 3 |
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
|
| 4 |
import gradio as gr
|
| 5 |
import sox
|
| 6 |
-
|
| 7 |
|
| 8 |
def convert(inputfile, outfile):
|
| 9 |
sox_tfm = sox.Transformer()
|
|
@@ -11,11 +11,12 @@ def convert(inputfile, outfile):
|
|
| 11 |
file_type="wav", channels=1, encoding="signed-integer", rate=16000, bits=16
|
| 12 |
)
|
| 13 |
sox_tfm.build(inputfile, outfile)
|
| 14 |
-
|
| 15 |
|
|
|
|
|
|
|
| 16 |
model_name = "indonesian-nlp/wav2vec2-indonesian-javanese-sundanese"
|
| 17 |
-
processor = Wav2Vec2Processor.from_pretrained(model_name)
|
| 18 |
-
model = Wav2Vec2ForCTC.from_pretrained(model_name)
|
| 19 |
|
| 20 |
def parse_transcription(wav_file):
|
| 21 |
filename = wav_file.name.split('.')[0]
|
|
@@ -30,16 +31,16 @@ def parse_transcription(wav_file):
|
|
| 30 |
|
| 31 |
|
| 32 |
output = gr.outputs.Textbox(label="Indonesian, Javanese or Sundanese")
|
| 33 |
-
|
| 34 |
-
input_ = gr.inputs.Audio(source="microphone", type="file")
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
gr.Interface(parse_transcription, inputs = input_, outputs=[output],
|
| 39 |
analytics_enabled=False,
|
| 40 |
show_tips=False,
|
| 41 |
theme='huggingface',
|
| 42 |
layout='vertical',
|
| 43 |
title="Multilingual Speech Recognition for Indonesian Languages",
|
| 44 |
-
description="Speech Recognition
|
|
|
|
|
|
|
| 45 |
enable_queue=True).launch( inline=False)
|
|
|
|
| 3 |
from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
|
| 4 |
import gradio as gr
|
| 5 |
import sox
|
| 6 |
+
import os
|
| 7 |
|
| 8 |
def convert(inputfile, outfile):
|
| 9 |
sox_tfm = sox.Transformer()
|
|
|
|
| 11 |
file_type="wav", channels=1, encoding="signed-integer", rate=16000, bits=16
|
| 12 |
)
|
| 13 |
sox_tfm.build(inputfile, outfile)
|
|
|
|
| 14 |
|
| 15 |
+
|
| 16 |
+
api_token = os.getenv("API_TOKEN")
|
| 17 |
model_name = "indonesian-nlp/wav2vec2-indonesian-javanese-sundanese"
|
| 18 |
+
processor = Wav2Vec2Processor.from_pretrained(model_name, use_auth_token=api_token)
|
| 19 |
+
model = Wav2Vec2ForCTC.from_pretrained(model_name, use_auth_token=api_token)
|
| 20 |
|
| 21 |
def parse_transcription(wav_file):
|
| 22 |
filename = wav_file.name.split('.')[0]
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
output = gr.outputs.Textbox(label="Indonesian, Javanese or Sundanese")
|
| 34 |
+
|
| 35 |
+
input_ = gr.inputs.Audio(source="microphone", type="file")
|
| 36 |
+
|
| 37 |
+
gr.Interface(parse_transcription, inputs=input_, outputs=[output],
|
|
|
|
|
|
|
| 38 |
analytics_enabled=False,
|
| 39 |
show_tips=False,
|
| 40 |
theme='huggingface',
|
| 41 |
layout='vertical',
|
| 42 |
title="Multilingual Speech Recognition for Indonesian Languages",
|
| 43 |
+
description="This is Speech Recognition live demo for Indonesian, Javanese and Sundanese Language. It uses"
|
| 44 |
+
"the Wav2Vec2 large model \"indonesian-nlp/wav2vec2-indonesian-javanese-sundanese\""
|
| 45 |
+
" fine-tuned on Common Voice and OpenSLR speech datasets.",
|
| 46 |
enable_queue=True).launch( inline=False)
|