Update app.py
Browse files
app.py
CHANGED
@@ -13,12 +13,19 @@ def synthesize_speech(text):
|
|
13 |
# Check for NSFW content
|
14 |
nsfw_result = nsfw_detector(text)
|
15 |
if nsfw_result[0]['label'] == 'NSFW':
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
model_path = hf_hub_download(repo_id="DLI-SLQ/speaker_01234", filename="speaker__01234_model.onnx")
|
19 |
-
config_path = hf_hub_download(repo_id="DLI-SLQ/speaker_01234", filename="speaker__01234_model.onnx.json")
|
20 |
-
voice = PiperVoice.load(model_path, config_path)
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
# Create an in-memory buffer for the WAV file
|
23 |
buffer = BytesIO()
|
24 |
with wave.open(buffer, 'wb') as wav_file:
|
|
|
13 |
# Check for NSFW content
|
14 |
nsfw_result = nsfw_detector(text)
|
15 |
if nsfw_result[0]['label'] == 'NSFW':
|
16 |
+
# Path to your default error audio file
|
17 |
+
error_audio_path = hf_hub_download(repo_id="aigmixer/speaker_00", filename= "error_audio.wav")
|
18 |
+
with open(error_audio_path, 'rb') as error_audio_file:
|
19 |
+
error_audio = error_audio_file.read()
|
20 |
+
return error_audio, "NSFW content detected. Cannot process."
|
21 |
|
|
|
|
|
|
|
22 |
|
23 |
+
model_path = hf_hub_download(repo_id="aigmixer/speaker_00", filename="speaker_00_model.onnx")
|
24 |
+
config_path = hf_hub_download(repo_id="aigmixer/speaker_00", filename="speaker_00_model.onnx.json")
|
25 |
+
|
26 |
+
|
27 |
+
voice = PiperVoice.load(model_path, config_path)
|
28 |
+
|
29 |
# Create an in-memory buffer for the WAV file
|
30 |
buffer = BytesIO()
|
31 |
with wave.open(buffer, 'wb') as wav_file:
|