Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,29 @@ import torch
|
|
| 4 |
import librosa
|
| 5 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, TextClassificationPipeline, AutoModelForTokenClassification, TokenClassificationPipeline, Wav2Vec2ForCTC, Wav2Vec2Processor, Wav2Vec2ProcessorWithLM
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def greet(name):
|
| 8 |
return "Hello " + name + "!!"
|
| 9 |
|
|
|
|
| 4 |
import librosa
|
| 5 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, TextClassificationPipeline, AutoModelForTokenClassification, TokenClassificationPipeline, Wav2Vec2ForCTC, Wav2Vec2Processor, Wav2Vec2ProcessorWithLM
|
| 6 |
|
| 7 |
+
# ASR
|
| 8 |
+
model_name = "jonatasgrosman/wav2vec2-large-xlsr-53-english"
|
| 9 |
+
processor_asr = Wav2Vec2Processor.from_pretrained(model_name)
|
| 10 |
+
model_asr = Wav2Vec2ForCTC.from_pretrained(model_name)
|
| 11 |
+
|
| 12 |
+
# Classifier Intent
|
| 13 |
+
model_name = 'qanastek/XLMRoberta-Alexa-Intents-Classification'
|
| 14 |
+
tokenizer_intent = AutoTokenizer.from_pretrained(model_name)
|
| 15 |
+
model_intent = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 16 |
+
classifier_intent = TextClassificationPipeline(model=model_intent, tokenizer=tokenizer_intent, device=0)
|
| 17 |
+
|
| 18 |
+
# Classifier Language
|
| 19 |
+
model_name = 'qanastek/51-languages-classifier'
|
| 20 |
+
tokenizer_langs = AutoTokenizer.from_pretrained(model_name)
|
| 21 |
+
model_langs = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 22 |
+
classifier_language = TextClassificationPipeline(model=model_langs, tokenizer=tokenizer_langs, device=0)
|
| 23 |
+
|
| 24 |
+
# NER Extractor
|
| 25 |
+
model_name = 'qanastek/XLMRoberta-Alexa-Intents-NER-NLU'
|
| 26 |
+
tokenizer_ner = AutoTokenizer.from_pretrained(model_name)
|
| 27 |
+
model_ner = AutoModelForTokenClassification.from_pretrained(model_name)
|
| 28 |
+
predict_ner = TokenClassificationPipeline(model=model_ner, tokenizer=tokenizer_ner, device=0)
|
| 29 |
+
|
| 30 |
def greet(name):
|
| 31 |
return "Hello " + name + "!!"
|
| 32 |
|