akhaliq3 commited on
Commit
c0b9ef2
1 Parent(s): b50efa0

remove app

Browse files
Files changed (1) hide show
  1. app.py +0 -21
app.py DELETED
@@ -1,21 +0,0 @@
1
- import soundfile as sf
2
- import gradio as gr
3
- import torch
4
- from transformers import Speech2Text2Processor, SpeechEncoderDecoder
5
- model = SpeechEncoderDecoder.from_pretrained("facebook/s2t-wav2vec2-large-en-de")
6
- processor = Speech2Text2Processor.from_pretrained("facebook/s2t-wav2vec2-large-en-de")
7
- def map_to_array(file):
8
- speech, _ = sf.read(file)
9
- return speech
10
-
11
- def inference(audio):
12
- inputs = processor(map_to_array(audio.name), sampling_rate=16_000, return_tensors="pt")
13
- generated_ids = model.generate(input_ids=inputs["input_features"], attention_mask=inputs["attention_mask"])
14
- transcription = processor.batch_decode(generated_ids)
15
- return transcription[0]
16
- inputs = gr.inputs.Audio(label="Input Audio", type="file")
17
- outputs = gr.outputs.Textbox(label="Output Text")
18
- title = "Robust wav2vec 2.0"
19
- description = "Gradio demo for Robust wav2vec 2.0. To use it, simply upload your audio, or click one of the examples to load them. Read more at the links below. Currently supports .wav and .flac files"
20
- article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2104.01027' target='_blank'>Robust wav2vec 2.0: Analyzing Domain Shift in Self-Supervised Pre-Training</a> | <a href='https://github.com/pytorch/fairseq' target='_blank'>Github Repo</a></p>"
21
- gr.Interface(inference, inputs, outputs, title=title, description=description, article=article).launch()