Rhueue commited on
Commit
c29f44b
·
1 Parent(s): 00faab9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -16,7 +16,7 @@ if uploaded_audio is not None:
16
 
17
  # Convert audio file to numpy array
18
  audio, sample_rate = sf.read(io.BytesIO(audio_bytes))
19
-
20
  # Apply noise reduction
21
  st.write("Applying noise reduction...")
22
  reduced_audio_data = nr.reduce_noise(y=audio, sr=sample_rate)
@@ -29,9 +29,12 @@ if uploaded_audio is not None:
29
  channels=1
30
  )
31
 
32
- # Slow down the audio by resampling
33
- st.write("Slowing down audio...")
34
- slowed_audio = reduced_audio.set_frame_rate(int(sample_rate * 0.7))
 
 
 
35
 
36
  # Export the slowed audio to a file
37
  slowed_audio.export("output_audio.wav", format="wav")
 
16
 
17
  # Convert audio file to numpy array
18
  audio, sample_rate = sf.read(io.BytesIO(audio_bytes))
19
+
20
  # Apply noise reduction
21
  st.write("Applying noise reduction...")
22
  reduced_audio_data = nr.reduce_noise(y=audio, sr=sample_rate)
 
29
  channels=1
30
  )
31
 
32
+ # Save the reduced audio as a 16-bit wave file
33
+ reduced_audio.export("reduced_audio.wav", format="wav")
34
+
35
+ # Load the 16-bit wave file and slow it down
36
+ slowed_audio = AudioSegment.from_wav("reduced_audio.wav")
37
+ slowed_audio = slowed_audio.speedup(playback_speed=0.7)
38
 
39
  # Export the slowed audio to a file
40
  slowed_audio.export("output_audio.wav", format="wav")