AbirMessaoudi commited on
Commit
a808f78
·
verified ·
1 Parent(s): 1619dcb

bug_fix env (#47)

Browse files

- clean code, requirements compatibility check (524ec453999a3139fc3d9e33dec15a8ac0af6e4f)

app.py CHANGED
@@ -1,22 +1,38 @@
1
  import os
2
  import gradio as gr
3
  import spaces
4
-
5
  from whisper_cs_fase_1 import generate_fase_1
6
  from whisper_cs_fase_2 import generate_fase_2
7
  from AinaTheme import theme
8
 
9
- @spaces.GPU()
10
- def transcribe_fase_1(inputs: str, model_version: str, civil_channel: str):
11
- if inputs is None:
12
- raise gr.Error("Cap fitxer d'àudio introduit! Si us plau pengeu un fitxer o enregistreu un àudio abans d'enviar la vostra sol·licitud")
13
- return generate_fase_1(audio_path=inputs, model_version=model_version, civil_channel=civil_channel)
14
 
15
- @spaces.GPU()
16
- def transcribe_fase_2_display(inputs: str, model_version: str, civil_channel: str):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  if inputs is None:
18
- raise gr.Error("Cap fitxer d'àudio introduit! Si us plau pengeu un fitxer o enregistreu un àudio abans d'enviar la vostra sol·licitud")
19
- return generate_fase_2(audio_path=inputs, model_version=model_version, civil_channel=civil_channel)
 
 
20
 
21
 
22
  def clear_fase_1(model_version, civil_channel):
@@ -27,16 +43,17 @@ def clear_fase_2(model_version, civil_channel):
27
 
28
 
29
  with gr.Blocks(theme=theme) as demo:
 
30
  gr.Markdown("## 🗣️ Transcripció automàtica d'àudio — Mode amb dues fases")
31
 
32
  with gr.Tabs():
33
  with gr.Tab("Fase 1"):
34
- description_string = (
 
35
  "### 🎧 Transcripció de trucades multilingüe de bona qualitat per a transcripció fiable\n"
36
  "- **v2_fast**: Inclou separació de canals i inferència ràpida.\n"
37
  "- **v1.0**: Inclou inferència moderada sense separació de canals."
38
  )
39
- gr.Markdown(description_string)
40
 
41
  with gr.Row():
42
  with gr.Column(scale=1):
@@ -46,28 +63,45 @@ with gr.Blocks(theme=theme) as demo:
46
  value="v2_fast",
47
  elem_id="fase1-model-version",
48
  )
 
49
  civil_channel_1 = gr.Dropdown(
50
  label="Canal del Civil (persona que truca)",
51
  choices=["Left", "Right"],
52
  value="Left",
53
  )
54
- input_1 = gr.Audio(sources=["upload", "microphone"], type="filepath", label="Audio")
 
 
 
 
 
 
55
  with gr.Column(scale=1):
56
  output_1 = gr.Textbox(label="Output", lines=8)
57
 
58
- with gr.Row(variant="panel"):
59
- clear_btn = gr.Button("Clear")
60
- submit_btn = gr.Button("Submit", variant="primary")
 
 
 
 
 
 
61
 
62
- submit_btn.click(fn=transcribe_fase_1, inputs=[input_1, model_version_1, civil_channel_1], outputs=[output_1])
63
- clear_btn.click(fn=clear_fase_1, inputs=[model_version_1, civil_channel_1], outputs=[input_1, model_version_1, civil_channel_1], queue=False)
 
 
 
 
64
 
65
  with gr.Tab("Fase 2"):
66
- description_string = (
 
67
  "### 🧠 Transcripció de trucades multilingüe de bona qualitat per a anàlisi d'informe\n"
68
- "- **v2_fast_and_detection_v1**: Inclou inferència ràpida, separació de parlants i explotació de nova informació per processos analítics i informes avançats."
69
  )
70
- gr.Markdown(description_string)
71
 
72
  with gr.Row():
73
  with gr.Column(scale=1):
@@ -77,33 +111,60 @@ with gr.Blocks(theme=theme) as demo:
77
  value="v2_fast_and_detection_v1",
78
  elem_id="fase2-model-version",
79
  )
 
80
  civil_channel_2 = gr.Dropdown(
81
  label="Canal del Civil (persona que truca)",
82
  choices=["Left", "Right"],
83
  value="Left",
84
  )
85
- input_2 = gr.Audio(sources=["upload", "microphone"], type="filepath", label="Audio")
 
 
 
 
 
 
86
  with gr.Column(scale=1):
87
  output_text = gr.Textbox(label="Transcripció ASR", lines=8)
88
  output_sex = gr.Textbox(label="Gènere", lines=1)
89
  output_age = gr.Textbox(label="Edat", lines=1)
90
  output_silence = gr.Textbox(label="Detecció de silenci", lines=2)
91
  output_shout = gr.Textbox(label="Detecció de crits", lines=2)
92
- output_meteo = gr.Textbox(label="Detecció d'esdeveniment meteorològic", lines=2)
93
-
94
- with gr.Row(variant="panel"):
95
- clear_btn2 = gr.Button("Clear")
96
- submit_btn2 = gr.Button("Submit", variant="primary")
97
-
98
- submit_btn2.click(
99
- fn=transcribe_fase_2_display,
100
- inputs=[input_2, model_version_2, civil_channel_2],
101
- outputs=[output_text, output_sex, output_age, output_silence, output_shout, output_meteo]
102
- )
103
-
104
- clear_btn2.click(fn=clear_fase_2, inputs=[model_version_2, civil_channel_2], outputs=[input_2, model_version_2, civil_channel_2, output_text, output_sex, output_age, output_silence, output_shout, output_meteo], queue=False)
 
 
 
 
 
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  if __name__ == "__main__":
108
  demo.launch()
109
-
 
1
  import os
2
  import gradio as gr
3
  import spaces
 
4
  from whisper_cs_fase_1 import generate_fase_1
5
  from whisper_cs_fase_2 import generate_fase_2
6
  from AinaTheme import theme
7
 
 
 
 
 
 
8
 
9
+ def generate_fase(audio_path, model_version, civil_channel, fase):
10
+ if fase == 1:
11
+ text = generate_fase_1(
12
+ audio_path,
13
+ model_version=model_version,
14
+ civil_channel=civil_channel
15
+ )
16
+ return text, None, None, None, None, None
17
+
18
+ elif fase == 2:
19
+ text, sex, age, silence_event, shout_event, meteo_event = generate_fase_2(
20
+ audio_path,
21
+ model_version=model_version,
22
+ civil_channel=civil_channel
23
+ )
24
+ return text, sex, age, silence_event, shout_event, meteo_event
25
+
26
+ else:
27
+ raise ValueError("Invalid fase. Must be 1 or 2.")
28
+
29
+ @spaces.GPU
30
+ def transcribe(inputs: str, model_version: str, civil_channel: str, fase: int):
31
  if inputs is None:
32
+ raise gr.Error(
33
+ "Cap fitxer d'àudio introduit! Si us plau pengeu un fitxer o enregistreu un àudio abans d'enviar la vostra sol·licitud"
34
+ )
35
+ return generate_fase(inputs, model_version, civil_channel, fase)
36
 
37
 
38
  def clear_fase_1(model_version, civil_channel):
 
43
 
44
 
45
  with gr.Blocks(theme=theme) as demo:
46
+
47
  gr.Markdown("## 🗣️ Transcripció automàtica d'àudio — Mode amb dues fases")
48
 
49
  with gr.Tabs():
50
  with gr.Tab("Fase 1"):
51
+
52
+ gr.Markdown(
53
  "### 🎧 Transcripció de trucades multilingüe de bona qualitat per a transcripció fiable\n"
54
  "- **v2_fast**: Inclou separació de canals i inferència ràpida.\n"
55
  "- **v1.0**: Inclou inferència moderada sense separació de canals."
56
  )
 
57
 
58
  with gr.Row():
59
  with gr.Column(scale=1):
 
63
  value="v2_fast",
64
  elem_id="fase1-model-version",
65
  )
66
+
67
  civil_channel_1 = gr.Dropdown(
68
  label="Canal del Civil (persona que truca)",
69
  choices=["Left", "Right"],
70
  value="Left",
71
  )
72
+
73
+ input_1 = gr.Audio(
74
+ sources=["upload", "microphone"],
75
+ type="filepath",
76
+ label="Audio",
77
+ )
78
+
79
  with gr.Column(scale=1):
80
  output_1 = gr.Textbox(label="Output", lines=8)
81
 
82
+ with gr.Row(variant="panel"):
83
+ clear_btn = gr.Button("Clear")
84
+ submit_btn = gr.Button("Submit", variant="primary")
85
+
86
+ submit_btn.click(
87
+ fn=transcribe,
88
+ inputs=[input_1, model_version_1, civil_channel_1, gr.Number(value=1)],
89
+ outputs=[output_1],
90
+ )
91
 
92
+ clear_btn.click(
93
+ fn=clear_fase_1,
94
+ inputs=[model_version_1, civil_channel_1],
95
+ outputs=[input_1, model_version_1, civil_channel_1],
96
+ queue=False,
97
+ )
98
 
99
  with gr.Tab("Fase 2"):
100
+
101
+ gr.Markdown(
102
  "### 🧠 Transcripció de trucades multilingüe de bona qualitat per a anàlisi d'informe\n"
103
+ "- **v2_fast_and_detection_v1**: Inclou inferència ràpida, separació de parlants i explotació d'informació detectada."
104
  )
 
105
 
106
  with gr.Row():
107
  with gr.Column(scale=1):
 
111
  value="v2_fast_and_detection_v1",
112
  elem_id="fase2-model-version",
113
  )
114
+
115
  civil_channel_2 = gr.Dropdown(
116
  label="Canal del Civil (persona que truca)",
117
  choices=["Left", "Right"],
118
  value="Left",
119
  )
120
+
121
+ input_2 = gr.Audio(
122
+ sources=["upload", "microphone"],
123
+ type="filepath",
124
+ label="Audio",
125
+ )
126
+
127
  with gr.Column(scale=1):
128
  output_text = gr.Textbox(label="Transcripció ASR", lines=8)
129
  output_sex = gr.Textbox(label="Gènere", lines=1)
130
  output_age = gr.Textbox(label="Edat", lines=1)
131
  output_silence = gr.Textbox(label="Detecció de silenci", lines=2)
132
  output_shout = gr.Textbox(label="Detecció de crits", lines=2)
133
+ output_meteo = gr.Textbox(label="Detecció meteo", lines=2)
134
+
135
+ with gr.Row(variant="panel"):
136
+ clear_btn2 = gr.Button("Clear")
137
+ submit_btn2 = gr.Button("Submit", variant="primary")
138
+
139
+ submit_btn2.click(
140
+ fn=transcribe,
141
+ inputs=[input_2, model_version_2, civil_channel_2, gr.Number(value=2)],
142
+ outputs=[
143
+ output_text,
144
+ output_sex,
145
+ output_age,
146
+ output_silence,
147
+ output_shout,
148
+ output_meteo,
149
+ ],
150
+ )
151
 
152
+ clear_btn2.click(
153
+ fn=clear_fase_2,
154
+ inputs=[model_version_2, civil_channel_2],
155
+ outputs=[
156
+ input_2,
157
+ model_version_2,
158
+ civil_channel_2,
159
+ output_text,
160
+ output_sex,
161
+ output_age,
162
+ output_silence,
163
+ output_shout,
164
+ output_meteo,
165
+ ],
166
+ queue=False,
167
+ )
168
 
169
  if __name__ == "__main__":
170
  demo.launch()
 
pyannote/config.yaml DELETED
@@ -1,18 +0,0 @@
1
- version: 3.1.0
2
-
3
- pipeline:
4
- name: pyannote.audio.pipelines.SpeakerDiarization
5
- params:
6
- clustering: AgglomerativeClustering
7
- embedding: ./pyannote/wespeaker-voxceleb-resnet34-LM.bin
8
- embedding_batch_size: 32
9
- embedding_exclude_overlap: false
10
- segmentation: ./pyannote/segmentation-3.0.bin
11
- segmentation_batch_size: 32
12
- params:
13
- clustering:
14
- method: centroid
15
- min_cluster_size: 12
16
- threshold: 0.7045654963945799
17
- segmentation:
18
- min_duration_off: 0.09791355693027545
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pyannote/pytorch_model.bin DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:0b5b3216d60a2d32fc086b47ea8c67589aaeb26b7e07fcbe620d6d0b83e209ea
3
- size 17719103
 
 
 
 
pyannote/segmentation-3.0.bin DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:da85c29829d4002daedd676e012936488234d9255e65e86dfab9bec6b1729298
3
- size 5905440
 
 
 
 
pyannote/wespeaker-voxceleb-resnet34-LM.bin DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:366edf44f4c80889a3eb7a9d7bdf02c4aede3127f7dd15e274dcdb826b143c56
3
- size 26645418
 
 
 
 
requirements.txt CHANGED
@@ -1,16 +1,20 @@
1
- torch
2
- torchaudio
3
- transformers==4.40.2 #gated models
4
- ctranslate2==4.6.0
 
5
  faster_whisper==1.2.0
 
 
6
  hf_transfer==0.1.9
7
- pyannote.audio==3.3.2
8
- yt-dlp==2025.7.21
9
- gradio==5.41.1
10
  librosa==0.10.1
 
11
  ffmpeg-python==0.2.0
 
 
 
12
  aina-gradio-theme==2.3
13
  spaces==0.39.0
14
- peft==0.11.1
15
- whisper_timestamped==1.15.8
16
  typing==3.7.4.3
 
 
1
+ torch==2.6.0+cu124 #speechbrain fix
2
+ torchaudio==2.6.0+cu124 #speechbrain fix
3
+ --extra-index-url https://download.pytorch.org/whl/cu124 #speechbrain fix
4
+ nvidia-cudnn-cu12>=9.1.0, <9.2 #ctranslate2 fix
5
+ ctranslate2>=4.3
6
  faster_whisper==1.2.0
7
+ whisper_timestamped==1.15.8
8
+ transformers==4.40.2
9
  hf_transfer==0.1.9
10
+ huggingface_hub
 
 
11
  librosa==0.10.1
12
+ soundfile
13
  ffmpeg-python==0.2.0
14
+ speechbrain
15
+ pydub
16
+ gradio==5.41.1
17
  aina-gradio-theme==2.3
18
  spaces==0.39.0
 
 
19
  typing==3.7.4.3
20
+ yt-dlp==2025.7.21