Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,27 @@
|
|
| 1 |
# app.py
|
| 2 |
import gradio as gr
|
| 3 |
-
import whisper
|
| 4 |
import spacy
|
| 5 |
import torch
|
| 6 |
import os
|
| 7 |
-
from
|
|
|
|
| 8 |
|
| 9 |
-
# Chargement
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
nlp = spacy.load("fr_core_news_md")
|
| 12 |
|
| 13 |
-
# Diarisation avec PyAnnote (
|
| 14 |
hf_token = os.getenv("HF_TOKEN")
|
| 15 |
if hf_token:
|
| 16 |
-
diar_pipeline =
|
| 17 |
else:
|
| 18 |
diar_pipeline = None
|
| 19 |
|
| 20 |
def process_audio(file):
|
| 21 |
-
|
|
|
|
| 22 |
transcription = result["text"]
|
| 23 |
|
| 24 |
# Diarisation
|
|
|
|
| 1 |
# app.py
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
import spacy
|
| 4 |
import torch
|
| 5 |
import os
|
| 6 |
+
from transformers import pipeline
|
| 7 |
+
from pyannote.audio import Pipeline as DiarizationPipeline
|
| 8 |
|
| 9 |
+
# Chargement du modèle Whisper via transformers
|
| 10 |
+
asr_pipeline = pipeline("automatic-speech-recognition", model="openai/whisper-small", chunk_length_s=30)
|
| 11 |
+
|
| 12 |
+
# Chargement du modèle spaCy pour NER
|
| 13 |
nlp = spacy.load("fr_core_news_md")
|
| 14 |
|
| 15 |
+
# Diarisation avec PyAnnote (si HF_TOKEN dispo dans l'environnement)
|
| 16 |
hf_token = os.getenv("HF_TOKEN")
|
| 17 |
if hf_token:
|
| 18 |
+
diar_pipeline = DiarizationPipeline.from_pretrained("pyannote/speaker-diarization-3.1", use_auth_token=hf_token)
|
| 19 |
else:
|
| 20 |
diar_pipeline = None
|
| 21 |
|
| 22 |
def process_audio(file):
|
| 23 |
+
# Transcription avec Whisper via transformers
|
| 24 |
+
result = asr_pipeline(file)
|
| 25 |
transcription = result["text"]
|
| 26 |
|
| 27 |
# Diarisation
|