bcci commited on
Commit
eb95b12
·
verified ·
1 Parent(s): e810b8c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -67,7 +67,7 @@ def audio_tensor_to_pcm_bytes(audio_tensor: torch.Tensor) -> bytes:
67
  audio_np = audio_np.flatten()
68
  # Scale to int16 range.
69
  audio_int16 = np.int16(audio_np * 32767)
70
- return audio_int16
71
 
72
 
73
  # ------------------------------------------------------------------------------
@@ -99,10 +99,7 @@ def tts_streaming(text: str, voice: str = "af_heart", speed: float = 1.0):
99
  results = list(pipeline(chunk, voice=voice, speed=speed, split_pattern=None))
100
  for result in results:
101
  if result.audio is not None:
102
- print(f"Chunk {i}: Audio generated") # Debugging
103
- pcm_bytes = audio_tensor_to_pcm_bytes(result.audio)
104
- for i in range(0, len(pcm_bytes), 100):
105
- yield pcm_bytes[i:i + chunk_size].tobytes()
106
  else:
107
  print(f"Chunk {i}: No audio generated")
108
  except Exception as e:
 
67
  audio_np = audio_np.flatten()
68
  # Scale to int16 range.
69
  audio_int16 = np.int16(audio_np * 32767)
70
+ return audio_int16.tobytes()
71
 
72
 
73
  # ------------------------------------------------------------------------------
 
99
  results = list(pipeline(chunk, voice=voice, speed=speed, split_pattern=None))
100
  for result in results:
101
  if result.audio is not None:
102
+ yield audio_tensor_to_pcm_bytes(result.audio)
 
 
 
103
  else:
104
  print(f"Chunk {i}: No audio generated")
105
  except Exception as e: