bluenevus commited on
Commit
310ebea
·
verified ·
1 Parent(s): 5753bc2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py CHANGED
@@ -8,11 +8,17 @@ from huggingface_hub import snapshot_download, login
8
  import logging
9
  import os
10
  import spaces
 
11
 
12
  # Set up logging
13
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
14
  logger = logging.getLogger(__name__)
15
 
 
 
 
 
 
16
  def get_device():
17
  if torch.cuda.is_available():
18
  return torch.device("cuda")
@@ -119,6 +125,8 @@ def text_to_speech(text, voice):
119
  raise
120
 
121
  def mel_to_audio(mel):
 
 
122
  return np.zeros(24000, dtype=np.float32) # Placeholder: 1 second of silence
123
 
124
  @spaces.GPU()
@@ -140,6 +148,11 @@ def render_podcast(api_key, script, voice1, voice2, num_hosts):
140
  return (24000, np.zeros(24000, dtype=np.float32))
141
 
142
  podcast_audio = np.concatenate(audio_segments)
 
 
 
 
 
143
  return (24000, podcast_audio)
144
  except Exception as e:
145
  logger.error(f"Error rendering podcast: {str(e)}")
 
8
  import logging
9
  import os
10
  import spaces
11
+ import warnings
12
 
13
  # Set up logging
14
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
15
  logger = logging.getLogger(__name__)
16
 
17
+ # Suppress specific warnings
18
+ warnings.filterwarnings("ignore", category=UserWarning, message="Trying to convert audio automatically from float32 to 16-bit int format.")
19
+ warnings.filterwarnings("ignore", category=RuntimeWarning, message="invalid value encountered in divide")
20
+ warnings.filterwarnings("ignore", category=RuntimeWarning, message="invalid value encountered in cast")
21
+
22
  def get_device():
23
  if torch.cuda.is_available():
24
  return torch.device("cuda")
 
125
  raise
126
 
127
  def mel_to_audio(mel):
128
+ # Implement proper mel to audio conversion here
129
+ # For now, we'll return a placeholder audio
130
  return np.zeros(24000, dtype=np.float32) # Placeholder: 1 second of silence
131
 
132
  @spaces.GPU()
 
148
  return (24000, np.zeros(24000, dtype=np.float32))
149
 
150
  podcast_audio = np.concatenate(audio_segments)
151
+
152
+ # Ensure the audio is in the correct format for Gradio
153
+ podcast_audio = np.clip(podcast_audio, -1, 1)
154
+ podcast_audio = (podcast_audio * 32767).astype(np.int16)
155
+
156
  return (24000, podcast_audio)
157
  except Exception as e:
158
  logger.error(f"Error rendering podcast: {str(e)}")