Spaces:
Sleeping
Sleeping
Update kid_coach_pipeline.py
Browse files- kid_coach_pipeline.py +10 -6
kid_coach_pipeline.py
CHANGED
|
@@ -753,14 +753,17 @@ Generate 5 specific, actionable tips to improve this speech. Focus on the weakes
|
|
| 753 |
|
| 754 |
def _generate_avatar_voice(self, text: str, output_dir: str, gender: str = 'male') -> Optional[str]:
|
| 755 |
"""Generate avatar voice using TTS"""
|
| 756 |
-
try
|
| 757 |
-
|
| 758 |
-
|
| 759 |
-
|
| 760 |
-
|
|
|
|
|
|
|
| 761 |
if not self.tts_enabled or not self.tts_model:
|
| 762 |
return None
|
| 763 |
|
|
|
|
| 764 |
try:
|
| 765 |
# Generate unique filename
|
| 766 |
filename = f"avatar_{uuid.uuid4().hex[:8]}.wav"
|
|
@@ -769,7 +772,8 @@ Generate 5 specific, actionable tips to improve this speech. Focus on the weakes
|
|
| 769 |
# Generate speech
|
| 770 |
self.tts_model.tts_to_file(
|
| 771 |
text=text[:500], # Limit to first 500 chars for demo
|
| 772 |
-
file_path=output_path
|
|
|
|
| 773 |
)
|
| 774 |
|
| 775 |
# Return relative path (will be served by FastAPI)
|
|
|
|
| 753 |
|
| 754 |
def _generate_avatar_voice(self, text: str, output_dir: str, gender: str = 'male') -> Optional[str]:
|
| 755 |
"""Generate avatar voice using TTS"""
|
| 756 |
+
# 1. Define speaker (No try block needed here)
|
| 757 |
+
if gender == 'male':
|
| 758 |
+
speaker = "p225" # Male speaker
|
| 759 |
+
else:
|
| 760 |
+
speaker = "p226"
|
| 761 |
+
|
| 762 |
+
# 2. Check if TTS is enabled
|
| 763 |
if not self.tts_enabled or not self.tts_model:
|
| 764 |
return None
|
| 765 |
|
| 766 |
+
# 3. Try to generate the file
|
| 767 |
try:
|
| 768 |
# Generate unique filename
|
| 769 |
filename = f"avatar_{uuid.uuid4().hex[:8]}.wav"
|
|
|
|
| 772 |
# Generate speech
|
| 773 |
self.tts_model.tts_to_file(
|
| 774 |
text=text[:500], # Limit to first 500 chars for demo
|
| 775 |
+
file_path=output_path,
|
| 776 |
+
speaker=speaker # I added this so the 'speaker' logic above is actually used
|
| 777 |
)
|
| 778 |
|
| 779 |
# Return relative path (will be served by FastAPI)
|