RexChan commited on
Commit
fd326aa
·
verified ·
1 Parent(s): 91e3ff6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -8,7 +8,7 @@ from pydub import AudioSegment
8
  from IPython.display import Audio
9
  import os
10
  import accelerate
11
- import pyaudio
12
  import numpy as np
13
 
14
  # Create PyAudio object
@@ -18,7 +18,7 @@ SAMPLING_RATE = 16000
18
  vocals_data = bytes()
19
 
20
  # preprocess and crop audio file
21
- def audio_preprocess(input_file, in_data, frame_count, time_info, status):
22
 
23
  # Define callback function for audio processing
24
 
@@ -32,10 +32,14 @@ def audio_preprocess(input_file, in_data, frame_count, time_info, status):
32
 
33
  # Convert vocals to audio data
34
  vocals_data = vocals['vocals'].flatten().astype(np.int16).tobytes()
 
35
 
36
  # Return processed data for output
37
- return vocals_data, pyaudio.paContinue
38
 
 
 
 
39
  # Open stream for recording
40
  stream = p.open(format=pyaudio.paInt16, channels=1, rate=SAMPLING_RATE, input=True, output=True,
41
  frames_per_buffer=CHUNK_SIZE, stream_callback=process_audio)
@@ -80,8 +84,6 @@ def audio_preprocess(input_file, in_data, frame_count, time_info, status):
80
  return processed_audio
81
 
82
 
83
-
84
-
85
  # ASR transcription
86
  def asr_model(processed_audio):
87
  # load audio file
@@ -132,7 +134,7 @@ def senti_model(transcription):
132
  def main(input_file):
133
 
134
 
135
- processed_audio = audio_preprocess(input_file)
136
  transcription = asr_model(processed_audio)
137
  final_result = senti_model(transcription)
138
  st.write(final_result)
 
8
  from IPython.display import Audio
9
  import os
10
  import accelerate
11
+ #import pyaudio
12
  import numpy as np
13
 
14
  # Create PyAudio object
 
18
  vocals_data = bytes()
19
 
20
  # preprocess and crop audio file
21
+ def audio_preprocess(input_file): #, in_data, frame_count, time_info, status):
22
 
23
  # Define callback function for audio processing
24
 
 
32
 
33
  # Convert vocals to audio data
34
  vocals_data = vocals['vocals'].flatten().astype(np.int16).tobytes()
35
+ separated_audio = vocals_data
36
 
37
  # Return processed data for output
38
+ return vocals_data, pyaudio.paContinue, processed_audio
39
 
40
+
41
+ # audio processing 2?
42
+ def py_audio():
43
  # Open stream for recording
44
  stream = p.open(format=pyaudio.paInt16, channels=1, rate=SAMPLING_RATE, input=True, output=True,
45
  frames_per_buffer=CHUNK_SIZE, stream_callback=process_audio)
 
84
  return processed_audio
85
 
86
 
 
 
87
  # ASR transcription
88
  def asr_model(processed_audio):
89
  # load audio file
 
134
  def main(input_file):
135
 
136
 
137
+ separated_audio = audio_preprocess(input_file)
138
  transcription = asr_model(processed_audio)
139
  final_result = senti_model(transcription)
140
  st.write(final_result)