Closed PeterBan11 closed 3 months ago
Hi! I'd like to help you. To better understand and replicate your situation, could you please provide the following information?
Best regards,
Python 3.11
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()
self.chunk_size = 1024
self.sample_rate = 44100
self.window = parent
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)
Hello, everyone!
I want to open wav file for analyse with this code:
wavFile = wave.open(self.wavFileName, 'r') 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)
But i get this problem:
RuntimeWarning: invalid value encountered in cast r = pfi.execute(a, is_real, is_forward, fct)