Remsky commited on
Commit
d0c45ea
·
1 Parent(s): 9aea310

Update model version to v1.0.0 and adjust initialization logic for voice selection

Browse files
Files changed (3) hide show
  1. app.py +9 -5
  2. tts_factory.py +1 -1
  3. tts_model_v1.py +2 -1
app.py CHANGED
@@ -24,7 +24,7 @@ logging.getLogger('matplotlib').setLevel(logging.WARNING)
24
  logger = logging.getLogger(__name__)
25
  logger.debug("Starting app initialization...")
26
 
27
- def initialize_model(version="v0.19"):
28
  """Initialize model and get voices"""
29
  global model
30
  try:
@@ -388,7 +388,7 @@ with gr.Blocks(title="Kokoro TTS Demo", css=styling) as demo:
388
  version_dropdown = gr.Dropdown(
389
  label="Model Version",
390
  choices=["v0.19", "v1.0.0"],
391
- value="v0.19",
392
  allow_custom_value=False,
393
  multiselect=False
394
  )
@@ -398,11 +398,15 @@ with gr.Blocks(title="Kokoro TTS Demo", css=styling) as demo:
398
  choices=[], # Start empty, will be populated after initialization
399
  value=None,
400
  allow_custom_value=True,
401
- multiselect=True
402
  )
403
 
404
  def on_version_change(version):
405
- return initialize_model(version)
 
 
 
 
406
 
407
  version_dropdown.change(
408
  fn=on_version_change,
@@ -458,7 +462,7 @@ with gr.Blocks(title="Kokoro TTS Demo", css=styling) as demo:
458
 
459
  # Initialize voices on load with default version
460
  demo.load(
461
- fn=lambda: initialize_model("v0.19"),
462
  outputs=[voice_dropdown]
463
  )
464
 
 
24
  logger = logging.getLogger(__name__)
25
  logger.debug("Starting app initialization...")
26
 
27
+ def initialize_model(version="v1.0.0"):
28
  """Initialize model and get voices"""
29
  global model
30
  try:
 
388
  version_dropdown = gr.Dropdown(
389
  label="Model Version",
390
  choices=["v0.19", "v1.0.0"],
391
+ value="v1.0.0",
392
  allow_custom_value=False,
393
  multiselect=False
394
  )
 
398
  choices=[], # Start empty, will be populated after initialization
399
  value=None,
400
  allow_custom_value=True,
401
+ multiselect=False # Start with v1.0.0 which doesn't support multiselect
402
  )
403
 
404
  def on_version_change(version):
405
+ voices = initialize_model(version)
406
+ # Disable multiselect for v1.0.0 since it doesn't support voice mixing yet
407
+ if version == "v1.0.0":
408
+ return gr.update(choices=voices.choices, value=voices.value, multiselect=False)
409
+ return gr.update(choices=voices.choices, value=voices.value, multiselect=True)
410
 
411
  version_dropdown.change(
412
  fn=on_version_change,
 
462
 
463
  # Initialize voices on load with default version
464
  demo.load(
465
+ fn=lambda: initialize_model("v1.0.0"),
466
  outputs=[voice_dropdown]
467
  )
468
 
tts_factory.py CHANGED
@@ -5,7 +5,7 @@ class TTSFactory:
5
  """Factory class to create appropriate TTS model version"""
6
 
7
  @staticmethod
8
- def create_model(version="v0.19"):
9
  """Create TTS model instance for specified version
10
 
11
  Args:
 
5
  """Factory class to create appropriate TTS model version"""
6
 
7
  @staticmethod
8
+ def create_model(version="v1.0.0"):
9
  """Create TTS model instance for specified version
10
 
11
  Args:
tts_model_v1.py CHANGED
@@ -73,7 +73,8 @@ class TTSModelV1:
73
  text,
74
  voice=voice_name,
75
  speed=speed,
76
- split_pattern=r'\n+' # Default chunking pattern
 
77
  )
78
 
79
  # Process chunks
 
73
  text,
74
  voice=voice_name,
75
  speed=speed,
76
+ split_pattern=r'\n\n+', # Split on double newlines or more
77
+ preprocess_text=lambda t: t.replace('\n', ' ').replace(' ', ' ') # Replace single newlines with spaces
78
  )
79
 
80
  # Process chunks