TheStinger commited on
Commit
5e3d1e1
β€’
1 Parent(s): 798712f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -10,17 +10,17 @@ def main():
10
  gr.Markdown(
11
  """
12
  # <div align="center"> Ilaria Audio Analyzer πŸ’– (BETA) </div>
13
- Audio Analyzer Software by Ilaria, Help me on [Ko-Fi](https://ko-fi.com/ilariaowo)\n
14
- Special thanks to [Alex Murkoff](https://github.com/alexlnkp) for helping me coding it!
15
 
16
- Need help with AI? [Join AI Hub!](https://discord.gg/aihub)
17
  """
18
  )
19
 
20
  with gr.Row(elem_id=1):
21
  audio_input = gr.Audio(type='filepath')
22
- with gr.Column():
23
- create_spec_butt = gr.Button(value='Create Spectrogram And Get Info', variant='primary')
24
 
25
  with gr.Row(elem_id=2):
26
  output_markdown = gr.Markdown(value="", visible=True)
@@ -37,8 +37,9 @@ def create_spectrogram_and_get_info(audio_file):
37
  # Read the audio data from the file
38
  audio_data, sample_rate = sf.read(audio_file)
39
 
40
- # Flatten the audio data if it's not mono
41
- audio_data = audio_data.flatten() if len(audio_data.shape) > 1 else audio_data
 
42
 
43
  # Create the spectrogram
44
  plt.specgram(audio_data, Fs=sample_rate / 1, NFFT=4096, sides='onesided',
 
10
  gr.Markdown(
11
  """
12
  # <div align="center"> Ilaria Audio Analyzer πŸ’– (BETA) </div>
13
+ Audio Analyzer Software by Ilaria, Help me on Ko-Fi\n
14
+ Special thanks to Alex Murkoff for helping me coding it!
15
 
16
+ Need help with AI? Join AI Hub!
17
  """
18
  )
19
 
20
  with gr.Row(elem_id=1):
21
  audio_input = gr.Audio(type='filepath')
22
+ with gr.Column():
23
+ create_spec_butt = gr.Button(value='Create Spectrogram And Get Info', variant='primary')
24
 
25
  with gr.Row(elem_id=2):
26
  output_markdown = gr.Markdown(value="", visible=True)
 
37
  # Read the audio data from the file
38
  audio_data, sample_rate = sf.read(audio_file)
39
 
40
+ # Convert to mono if it's not mono
41
+ if len(audio_data.shape) > 1:
42
+ audio_data = np.mean(audio_data, axis=1)
43
 
44
  # Create the spectrogram
45
  plt.specgram(audio_data, Fs=sample_rate / 1, NFFT=4096, sides='onesided',