You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to open wav file for analyse with this code(but it doesn't work):
import os
import wave
import pyaudio
import numpy as np
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog
from pydub import AudioSegment
class Full:
def init(self, parent):
self.pa = pyaudio.PyAudio()
Hello, everyone!
I want to open wav file for analyse with this code(but it doesn't work):
import os
import wave
import pyaudio
import numpy as np
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog
from pydub import AudioSegment
class Full:
def init(self, parent):
self.pa = pyaudio.PyAudio()
def start_analyzing_WavFile(self):
try:
file_Extension = self.path.split(".")[1].lower()
if file_Extension == "wav":
wavFile = wave.open(self.wavFileName, 'r')
elif file_Extension == "mp3":
cwd = os.getcwd()
sound = AudioSegment.from_mp3(self.wavFileName)
self.wavFileName = f"{cwd}/tmp.wav"
sound.export(self.wavFileName, format="wav")
wavFile = wave.open(self.wavFileName, 'r')
else:
print(f"Unknown Type of File: {file_Extension}")
except IOError as e:
print(u'cant open wavFile file')
else:
with wavFile:
self.stream = self.pa.open(format=self.pa.get_format_from_width(wavFile.getsampwidth()),
channels=wavFile.getnchannels(),
rate=wavFile.getframerate(),
input=True,
frames_per_buffer=self.chunk_size,
stream_callback=self.read_callback)
The text was updated successfully, but these errors were encountered: