Code Monkey home page Code Monkey logo

Comments (2)

Caparrini avatar Caparrini commented on June 11, 2024

Hi! I'd like to help you. To better understand and replicate your situation, could you please provide the following information?

  1. Which version of Python are you using?
  2. Your code references 'self', indicating it's part of a class. Could you provide more context or the object's class definition.
  3. It would be helpful to know which libraries you have installed. Running pip freeze in a terminal will list your installed libraries.

Best regards,

from pyaudioanalysis.

PeterBan11 avatar PeterBan11 commented on June 11, 2024

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)

from pyaudioanalysis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.