|
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline |
|
|
|
|
|
model_name = 'serge-wilson/sentiment_analysis_french' |
|
tokenizer = AutoTokenizer.from_pretrained(model_name) |
|
model = AutoModelForSequenceClassification.from_pretrained(model_name) |
|
|
|
|
|
classifier = pipeline("text-classification", model = model,tokenizer = tokenizer) |
|
transcriber = pipeline("automatic-speech-recognition", model="bhuang/asr-wav2vec2-french") |
|
|
|
|
|
def transcription_classification_pipeline(audio): |
|
""" |
|
Cette fonction fonction prend en entrée un audio et renvoie la transcription et la classe prédite |
|
""" |
|
|
|
|
|
transcription = transcriber(audio)["text"] |
|
|
|
|
|
result = classifier(transcription, truncation=True)[0] |
|
|
|
|
|
predicted_label = result.get("label") |
|
|
|
return transcription, predicted_label.capitalize() |