alakxender commited on
Commit
654c129
·
0 Parent(s):

Initial commit with current changes

Browse files
Files changed (6) hide show
  1. .gitattributes +35 -0
  2. .gitignore +1 -0
  3. README.md +12 -0
  4. app.py +68 -0
  5. packages.txt +1 -0
  6. requirements.txt +1 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz 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
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio_cached_examples
README.md ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Dhivehi Whisper Demo
3
+ emoji: 🏆
4
+ colorFrom: pink
5
+ colorTo: green
6
+ sdk: gradio
7
+ sdk_version: 5.7.1
8
+ app_file: app.py
9
+ pinned: false
10
+ ---
11
+
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import spaces
2
+ import torch
3
+
4
+ import gradio as gr
5
+ from transformers import pipeline
6
+ from transformers.pipelines.audio_utils import ffmpeg_read
7
+
8
+ import tempfile
9
+ import os
10
+
11
+ MODEL_NAME = "alakxender/whisper-large-dv-a40"
12
+ BATCH_SIZE = 8
13
+ FILE_LIMIT_MB = 1000
14
+
15
+ device = 0 if torch.cuda.is_available() else "cpu"
16
+
17
+ pipe = pipeline(
18
+ task="automatic-speech-recognition",
19
+ model=MODEL_NAME,
20
+ chunk_length_s=30,
21
+ device=device,
22
+ )
23
+
24
+
25
+ @spaces.GPU
26
+ def transcribe(inputs):
27
+ if inputs is None:
28
+ raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.")
29
+
30
+ text = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": "transcribe"}, return_timestamps=True)["text"]
31
+ return text
32
+
33
+
34
+ # Custom CSS with modern Gradio styling
35
+ custom_css = """
36
+ .thaana-textbox textarea {
37
+ font-size: 18px !important;
38
+ font-family: 'MV_Faseyha', 'Faruma', 'A_Faruma', 'Noto Sans Thaana', 'MV Boli' !important;
39
+ line-height: 1.8 !important;
40
+ direction: rtl !important;
41
+ }
42
+ """
43
+
44
+ demo = gr.Blocks(css=custom_css)
45
+
46
+ file_transcribe = gr.Interface(
47
+ fn=transcribe,
48
+ inputs=[
49
+ gr.Audio(sources="upload", type="filepath", label="Audio file"),
50
+ ],
51
+ outputs= gr.Textbox(
52
+ label="",
53
+ lines=2,
54
+ elem_classes=["thaana-textbox"],
55
+ rtl=True
56
+ ),
57
+ title="Whisper Large V3: Transcribe Audio",
58
+ description=(
59
+ ""
60
+ ),
61
+ allow_flagging="never",
62
+ )
63
+
64
+
65
+ with demo:
66
+ gr.TabbedInterface([file_transcribe], ["Audio file"])
67
+
68
+ demo.queue().launch()
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ ffmpeg
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ transformers