Update app.py
Browse files
app.py
CHANGED
@@ -25,10 +25,17 @@ def preprocess_text(text):
|
|
25 |
text = text.replace(term.upper(), phonetic)
|
26 |
return text
|
27 |
|
|
|
|
|
|
|
|
|
|
|
28 |
# Step 2: Define the TTS function with sentence segmentation
|
29 |
def text_to_speech(input_text):
|
30 |
# Preprocess and segment text
|
31 |
processed_text = preprocess_text(input_text)
|
|
|
|
|
32 |
# Split the processed text by punctuation to form shorter segments
|
33 |
segments = re.split(r'(?<=[.!?]) +', processed_text)
|
34 |
|
@@ -62,9 +69,9 @@ iface = gr.Interface(
|
|
62 |
title="Fine-tuning TTS for Technical Vocabulary",
|
63 |
description="Enter text with technical jargon for TTS conversion. The model will handle abbreviations and technical terms for better pronunciation.",
|
64 |
examples=[
|
65 |
-
["
|
66 |
-
["
|
67 |
-
["
|
68 |
]
|
69 |
)
|
70 |
|
|
|
25 |
text = text.replace(term.upper(), phonetic)
|
26 |
return text
|
27 |
|
28 |
+
# Explicitly replace "API" with "A P I" to improve pronunciation
|
29 |
+
def custom_acronym_pronunciation(text):
|
30 |
+
text = text.replace("API", "ay p eei")
|
31 |
+
return text
|
32 |
+
|
33 |
# Step 2: Define the TTS function with sentence segmentation
|
34 |
def text_to_speech(input_text):
|
35 |
# Preprocess and segment text
|
36 |
processed_text = preprocess_text(input_text)
|
37 |
+
# Apply custom acronym handling
|
38 |
+
processed_text = custom_acronym_pronunciation(processed_text)
|
39 |
# Split the processed text by punctuation to form shorter segments
|
40 |
segments = re.split(r'(?<=[.!?]) +', processed_text)
|
41 |
|
|
|
69 |
title="Fine-tuning TTS for Technical Vocabulary",
|
70 |
description="Enter text with technical jargon for TTS conversion. The model will handle abbreviations and technical terms for better pronunciation.",
|
71 |
examples=[
|
72 |
+
["The API allows integration with OAuth and REST for scalable web services."],
|
73 |
+
["Using CUDA for deep learning optimizes the model training on GPUs."],
|
74 |
+
["In TTS models, the vocoder is essential for natural-sounding speech."]
|
75 |
]
|
76 |
)
|
77 |
|