Omarrran commited on
Commit
8454042
·
verified ·
1 Parent(s): 968d3a5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -231,7 +231,7 @@ class TTSDatasetCollector:
231
 
232
  # Save the font file
233
  with open(font_dest, 'wb') as f:
234
- f.write(font_file.getvalue())
235
 
236
  # Add to custom fonts
237
  self.custom_fonts[font_family] = {
@@ -257,6 +257,7 @@ class TTSDatasetCollector:
257
  """Generate unique filenames for audio and text files"""
258
  line_number = self.current_index + 1
259
  timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
 
260
  # Sanitize strings for filenames
261
  def sanitize_filename(s):
262
  return re.sub(r'[^a-zA-Z0-9_-]', '_', s)[:50]
@@ -469,7 +470,7 @@ Font_Style: {metadata['font_style']}
469
  metadata = json.load(f)
470
  # Flatten statistics for display
471
  total_sentences = len(self.sentences)
472
- recorded = sum(len(dataset['recorded_sentences']) for speaker in metadata['speakers'].values() for dataset in speaker['datasets'].values())
473
  remaining = total_sentences - recorded
474
  stats = {
475
  "Total Sentences": total_sentences,
@@ -646,7 +647,7 @@ def create_interface():
646
  }
647
 
648
  nav_info = collector.get_navigation_info()
649
- progress_bar = progress.update(value=f"<progress value='{collector.current_index + 1}' max='{len(collector.sentences)}'></progress> {nav_info['progress']}")
650
  return {
651
  current_text: nav_info['current'],
652
  next_text: nav_info['next'],
@@ -690,7 +691,7 @@ def create_interface():
690
  }
691
 
692
  nav_info = collector.get_navigation_info()
693
- progress_bar = progress.update(value=f"<progress value='{collector.current_index + 1}' max='{len(collector.sentences)}'></progress> {nav_info['progress']}")
694
  return {
695
  current_text: nav_info['current'],
696
  next_text: nav_info['next'],
@@ -726,7 +727,7 @@ def create_interface():
726
 
727
  # Auto-advance to next sentence after successful save
728
  nav_info = collector.navigate("next")
729
- progress_bar = progress.update(value=f"<progress value='{collector.current_index + 1}' max='{len(collector.sentences)}'></progress> {nav_info['progress']}")
730
  return {
731
  current_text: nav_info['current'],
732
  next_text: nav_info['next'],
@@ -740,7 +741,7 @@ def create_interface():
740
  def navigate_sentences(direction):
741
  """Handle navigation between sentences"""
742
  nav_info = collector.navigate(direction)
743
- progress_bar = progress.update(value=f"<progress value='{collector.current_index + 1}' max='{len(collector.sentences)}'></progress> {nav_info['progress']}")
744
  return {
745
  current_text: nav_info['current'],
746
  next_text: nav_info['next'],
 
231
 
232
  # Save the font file
233
  with open(font_dest, 'wb') as f:
234
+ f.write(font_file.read())
235
 
236
  # Add to custom fonts
237
  self.custom_fonts[font_family] = {
 
257
  """Generate unique filenames for audio and text files"""
258
  line_number = self.current_index + 1
259
  timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
260
+
261
  # Sanitize strings for filenames
262
  def sanitize_filename(s):
263
  return re.sub(r'[^a-zA-Z0-9_-]', '_', s)[:50]
 
470
  metadata = json.load(f)
471
  # Flatten statistics for display
472
  total_sentences = len(self.sentences)
473
+ recorded = sum(len(dataset.get('recorded_sentences', [])) for speaker in metadata['speakers'].values() for dataset in speaker['datasets'].values())
474
  remaining = total_sentences - recorded
475
  stats = {
476
  "Total Sentences": total_sentences,
 
647
  }
648
 
649
  nav_info = collector.get_navigation_info()
650
+ progress_bar = f"<progress value='{collector.current_index + 1}' max='{len(collector.sentences)}'></progress> {nav_info['progress']}"
651
  return {
652
  current_text: nav_info['current'],
653
  next_text: nav_info['next'],
 
691
  }
692
 
693
  nav_info = collector.get_navigation_info()
694
+ progress_bar = f"<progress value='{collector.current_index + 1}' max='{len(collector.sentences)}'></progress> {nav_info['progress']}"
695
  return {
696
  current_text: nav_info['current'],
697
  next_text: nav_info['next'],
 
727
 
728
  # Auto-advance to next sentence after successful save
729
  nav_info = collector.navigate("next")
730
+ progress_bar = f"<progress value='{collector.current_index + 1}' max='{len(collector.sentences)}'></progress> {nav_info['progress']}"
731
  return {
732
  current_text: nav_info['current'],
733
  next_text: nav_info['next'],
 
741
  def navigate_sentences(direction):
742
  """Handle navigation between sentences"""
743
  nav_info = collector.navigate(direction)
744
+ progress_bar = f"<progress value='{collector.current_index + 1}' max='{len(collector.sentences)}'></progress> {nav_info['progress']}"
745
  return {
746
  current_text: nav_info['current'],
747
  next_text: nav_info['next'],