Spaces:
Running
on
Zero
Running
on
Zero
Tip error when create speaker failed
Browse files
app.py
CHANGED
@@ -104,13 +104,16 @@ def get_or_create_speaker(interface, audio_file):
|
|
104 |
|
105 |
# Create new speaker profile
|
106 |
print(f"🔄 Creating new speaker profile for {os.path.basename(audio_file)}")
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
114 |
|
115 |
@spaces.GPU
|
116 |
def create_speaker_and_generate(model_name, audio_file, test_text: Optional[str] = None, temperature: float = 0.4):
|
@@ -123,10 +126,14 @@ def create_speaker_and_generate(model_name, audio_file, test_text: Optional[str]
|
|
123 |
interface = get_interface(model_name)
|
124 |
|
125 |
# Get or create speaker profile (with caching)
|
126 |
-
|
|
|
|
|
|
|
|
|
127 |
|
128 |
# Convert speaker dict to formatted JSON
|
129 |
-
speaker_json = json.dumps(
|
130 |
|
131 |
# Generate test audio if text is provided
|
132 |
generated_audio = None
|
@@ -134,7 +141,7 @@ def create_speaker_and_generate(model_name, audio_file, test_text: Optional[str]
|
|
134 |
output = interface.generate(
|
135 |
config=outetts.GenerationConfig(
|
136 |
text=test_text,
|
137 |
-
speaker=
|
138 |
sampler_config=outetts.SamplerConfig(
|
139 |
temperature=temperature
|
140 |
),
|
@@ -162,7 +169,7 @@ demo = gr.Interface(
|
|
162 |
info="Choose the model variant to use"
|
163 |
),
|
164 |
gr.Audio(
|
165 |
-
label="Upload Reference Audio",
|
166 |
type="filepath",
|
167 |
sources=["upload", "microphone"]
|
168 |
),
|
|
|
104 |
|
105 |
# Create new speaker profile
|
106 |
print(f"🔄 Creating new speaker profile for {os.path.basename(audio_file)}")
|
107 |
+
try:
|
108 |
+
speaker = interface.create_speaker(audio_file, whisper_model="large-v3-turbo", whisper_device=device)
|
109 |
+
|
110 |
+
# Cache the speaker profile
|
111 |
+
speaker_cache[cache_key] = speaker
|
112 |
+
print(f"💾 Cached speaker profile ({len(speaker_cache)} total cached)")
|
113 |
+
|
114 |
+
return speaker
|
115 |
+
except Exception as e:
|
116 |
+
return f"❌ Error creating speaker profile: {str(e)}"
|
117 |
|
118 |
@spaces.GPU
|
119 |
def create_speaker_and_generate(model_name, audio_file, test_text: Optional[str] = None, temperature: float = 0.4):
|
|
|
126 |
interface = get_interface(model_name)
|
127 |
|
128 |
# Get or create speaker profile (with caching)
|
129 |
+
speaker_result = get_or_create_speaker(interface, audio_file)
|
130 |
+
|
131 |
+
# Check if speaker_result is an error message
|
132 |
+
if isinstance(speaker_result, str) and speaker_result.startswith("❌"):
|
133 |
+
return speaker_result, None
|
134 |
|
135 |
# Convert speaker dict to formatted JSON
|
136 |
+
speaker_json = json.dumps(speaker_result, indent=2, ensure_ascii=False)
|
137 |
|
138 |
# Generate test audio if text is provided
|
139 |
generated_audio = None
|
|
|
141 |
output = interface.generate(
|
142 |
config=outetts.GenerationConfig(
|
143 |
text=test_text,
|
144 |
+
speaker=speaker_result,
|
145 |
sampler_config=outetts.SamplerConfig(
|
146 |
temperature=temperature
|
147 |
),
|
|
|
169 |
info="Choose the model variant to use"
|
170 |
),
|
171 |
gr.Audio(
|
172 |
+
label="Upload Reference Audio (Max 20 seconds)",
|
173 |
type="filepath",
|
174 |
sources=["upload", "microphone"]
|
175 |
),
|