Manasa1 commited on
Commit
e38508f
·
verified ·
1 Parent(s): c4494a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -4,12 +4,12 @@ from pydub import AudioSegment
4
  def sine_wave(frequency, duration_ms):
5
  """Generate a sine wave tone at a given frequency and duration."""
6
  sample_rate = 44100 # Sample rate in Hz
7
- t = np.linspace(0, duration_ms / 1000, int(sample_rate * (duration_ms / 1000)), False)
8
  wave = 0.5 * np.sin(2 * np.pi * frequency * t) # Sine wave formula
9
  audio_segment = AudioSegment(
10
- wave.tobytes(),
11
  frame_rate=sample_rate,
12
- sample_width=2, # 16-bit audio
13
  channels=1 # Mono audio
14
  )
15
  return audio_segment
@@ -47,6 +47,7 @@ def generate_kids_music(theme):
47
  return output_file
48
 
49
 
 
50
  from transformers import pipeline
51
 
52
  # Load the GPT-2 model for text generation
 
4
  def sine_wave(frequency, duration_ms):
5
  """Generate a sine wave tone at a given frequency and duration."""
6
  sample_rate = 44100 # Sample rate in Hz
7
+ t = np.linspace(0, duration_ms / 1000, int(sample_rate * (duration_ms / 1000)), endpoint=False)
8
  wave = 0.5 * np.sin(2 * np.pi * frequency * t) # Sine wave formula
9
  audio_segment = AudioSegment(
10
+ (wave * 32767).astype(np.int16).tobytes(), # Convert to 16-bit PCM
11
  frame_rate=sample_rate,
12
+ sample_width=2, # 16 bits
13
  channels=1 # Mono audio
14
  )
15
  return audio_segment
 
47
  return output_file
48
 
49
 
50
+
51
  from transformers import pipeline
52
 
53
  # Load the GPT-2 model for text generation