Spaces:
Sleeping
Sleeping
Fixed bug in preprocessing script
Browse files- .gitattributes +1 -0
- app.py +11 -2
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
.env
|
app.py
CHANGED
@@ -5,6 +5,13 @@ import numpy as np
|
|
5 |
import webrtcvad
|
6 |
from transformers import WhisperProcessor, WhisperForConditionalGeneration, pipeline
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
# Model names
|
9 |
TN_MODEL_NAME = "amenIKh/Tunisian_Checkpoint12"
|
10 |
WHISPER_MODEL_NAME = "openai/whisper-small"
|
@@ -14,11 +21,13 @@ pipe_tn = pipeline(
|
|
14 |
task="automatic-speech-recognition",
|
15 |
model=TN_MODEL_NAME,
|
16 |
device=0 if torch.cuda.is_available() else -1,
|
|
|
|
|
17 |
)
|
18 |
|
19 |
# Load Whisper model and processor
|
20 |
-
whisper_model = WhisperForConditionalGeneration.from_pretrained(WHISPER_MODEL_NAME)
|
21 |
-
whisper_processor = WhisperProcessor.from_pretrained(WHISPER_MODEL_NAME)
|
22 |
|
23 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
24 |
whisper_model.to(device)
|
|
|
5 |
import webrtcvad
|
6 |
from transformers import WhisperProcessor, WhisperForConditionalGeneration, pipeline
|
7 |
|
8 |
+
from dotenv import load_dotenv
|
9 |
+
import os
|
10 |
+
|
11 |
+
load_dotenv() # Loads the .env file
|
12 |
+
token = os.getenv("HUGGINGFACE_TOKEN")
|
13 |
+
|
14 |
+
|
15 |
# Model names
|
16 |
TN_MODEL_NAME = "amenIKh/Tunisian_Checkpoint12"
|
17 |
WHISPER_MODEL_NAME = "openai/whisper-small"
|
|
|
21 |
task="automatic-speech-recognition",
|
22 |
model=TN_MODEL_NAME,
|
23 |
device=0 if torch.cuda.is_available() else -1,
|
24 |
+
use_auth_token=token
|
25 |
+
|
26 |
)
|
27 |
|
28 |
# Load Whisper model and processor
|
29 |
+
whisper_model = WhisperForConditionalGeneration.from_pretrained(WHISPER_MODEL_NAME,use_auth_token=token)
|
30 |
+
whisper_processor = WhisperProcessor.from_pretrained(WHISPER_MODEL_NAME,use_auth_token=token)
|
31 |
|
32 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
33 |
whisper_model.to(device)
|