Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -90,7 +90,7 @@ def process_audio(
|
|
90 |
diarize: bool = True,
|
91 |
enhance: bool = True,
|
92 |
anonymize: bool = True
|
93 |
-
) ->
|
94 |
"""
|
95 |
Ses dosyasını işleyip transkripsiyon yapar.
|
96 |
|
@@ -101,10 +101,10 @@ def process_audio(
|
|
101 |
anonymize: Kişisel veriler anonimleştirilsin mi?
|
102 |
|
103 |
Returns:
|
104 |
-
|
105 |
"""
|
106 |
if not audio_path:
|
107 |
-
return "Lütfen bir ses dosyası yükleyin."
|
108 |
|
109 |
try:
|
110 |
# Ses dosyasını WAV formatına çevir
|
@@ -130,20 +130,12 @@ def process_audio(
|
|
130 |
if anonymize:
|
131 |
result = anonymize_personal_info(result)
|
132 |
|
133 |
-
|
134 |
-
json_result = {
|
135 |
-
"transcript": result["text"],
|
136 |
-
"diarization": diarization,
|
137 |
-
"enhanced_audio": wav_path if enhance else None,
|
138 |
-
"anonymized": anonymize
|
139 |
-
}
|
140 |
-
|
141 |
-
return result["text"], json.dumps(json_result, ensure_ascii=False)
|
142 |
|
143 |
except Exception as e:
|
144 |
error_msg = f"İşlem sırasında bir hata oluştu: {str(e)}"
|
145 |
print(error_msg)
|
146 |
-
return error_msg
|
147 |
|
148 |
# Ana arayüz
|
149 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="indigo", secondary_hue="blue"), css=css) as demo:
|
@@ -180,9 +172,6 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="indigo", secondary_hue="blue"),
|
|
180 |
with gr.TabItem("Konuşma Metni"):
|
181 |
result_text = gr.Markdown(label="Transkripsiyon Sonucu", elem_classes="result-text")
|
182 |
|
183 |
-
with gr.TabItem("JSON Sonucu"):
|
184 |
-
json_output = gr.JSON(label="API Yanıtı")
|
185 |
-
|
186 |
with gr.TabItem("Kullanım Kılavuzu"):
|
187 |
gr.Markdown(usage_tips)
|
188 |
|
@@ -221,12 +210,12 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="indigo", secondary_hue="blue"),
|
|
221 |
process_btn.click(
|
222 |
fn=process_audio,
|
223 |
inputs=[audio_input, diarize, enhance, anonymize],
|
224 |
-
outputs=
|
225 |
)
|
226 |
|
227 |
clear_btn.click(
|
228 |
-
lambda: (None,
|
229 |
-
outputs=[audio_input,
|
230 |
)
|
231 |
|
232 |
gr.HTML("""
|
|
|
90 |
diarize: bool = True,
|
91 |
enhance: bool = True,
|
92 |
anonymize: bool = True
|
93 |
+
) -> str:
|
94 |
"""
|
95 |
Ses dosyasını işleyip transkripsiyon yapar.
|
96 |
|
|
|
101 |
anonymize: Kişisel veriler anonimleştirilsin mi?
|
102 |
|
103 |
Returns:
|
104 |
+
str: Transkripsiyon metni
|
105 |
"""
|
106 |
if not audio_path:
|
107 |
+
return "Lütfen bir ses dosyası yükleyin."
|
108 |
|
109 |
try:
|
110 |
# Ses dosyasını WAV formatına çevir
|
|
|
130 |
if anonymize:
|
131 |
result = anonymize_personal_info(result)
|
132 |
|
133 |
+
return result["text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
except Exception as e:
|
136 |
error_msg = f"İşlem sırasında bir hata oluştu: {str(e)}"
|
137 |
print(error_msg)
|
138 |
+
return error_msg
|
139 |
|
140 |
# Ana arayüz
|
141 |
with gr.Blocks(theme=gr.themes.Soft(primary_hue="indigo", secondary_hue="blue"), css=css) as demo:
|
|
|
172 |
with gr.TabItem("Konuşma Metni"):
|
173 |
result_text = gr.Markdown(label="Transkripsiyon Sonucu", elem_classes="result-text")
|
174 |
|
|
|
|
|
|
|
175 |
with gr.TabItem("Kullanım Kılavuzu"):
|
176 |
gr.Markdown(usage_tips)
|
177 |
|
|
|
210 |
process_btn.click(
|
211 |
fn=process_audio,
|
212 |
inputs=[audio_input, diarize, enhance, anonymize],
|
213 |
+
outputs=result_text
|
214 |
)
|
215 |
|
216 |
clear_btn.click(
|
217 |
+
lambda: (None, "Sistem hazır."),
|
218 |
+
outputs=[audio_input, status]
|
219 |
)
|
220 |
|
221 |
gr.HTML("""
|