Voice Audio Analysis Tool

Welcome to the Voice Audio Analysis Tool! This Python script utilizes the My-Voice-Analysis and pyAudioAnalysis libraries to perform comprehensive voice analysis on audio files. Below, you'll find the code and explanations for how to use this powerful tool.

Installation

First, ensure you have the required libraries installed:

pip install my-voice-analysis
pip install pyAudioAnalysis
pip install scipy matplotlib numpy sklearn hmmlearn simplejson eyed3 pydub
        

Python Script

import os
import My_Voice_Analysis as mva
from pyAudioAnalysis import audioBasicIO
from pyAudioAnalysis import audioFeatureExtraction
import matplotlib.pyplot as plt

def analyze_voice(file_path):
    # My-Voice-Analysis
    mva_results = mva.myspsolution(file_path)
    
    # pyAudioAnalysis
    [Fs, x] = audioBasicIO.read_audio_file(file_path)
    F, f_names = audioFeatureExtraction.stFeatureExtraction(x, Fs, 0.050*Fs, 0.025*Fs)
    
    return mva_results, F, f_names

def plot_features(F, f_names):
    plt.figure(figsize=(12, 8))
    for i in range(len(f_names)):
        plt.subplot(4, 5, i+1)
        plt.plot(F[i, :])
        plt.title(f_names[i])
    plt.tight_layout()
    plt.savefig('audio_features.png')
    plt.close()

def main():
    file_path = "path/to/your/audio/file.wav"
    
    mva_results, F, f_names = analyze_voice(file_path)
    
    print("My-Voice-Analysis Results:")
    for key, value in mva_results.items():
        print(f"{key}: {value}")
    
    print("\npyAudioAnalysis Features:")
    for i, name in enumerate(f_names):
        print(f"{name}: {F[i].mean()}")
    
    plot_features(F, f_names)
    print("\nAudio features plot saved as 'audio_features.png'")

if __name__ == "__main__":
    main()
        

How to Use

  1. Replace "path/to/your/audio/file.wav" with the actual path to your audio file.
  2. Run the script. It will analyze the audio using both My-Voice-Analysis and pyAudioAnalysis libraries.
  3. The script will print out various voice metrics and features extracted from the audio.
  4. A plot of the extracted features will be saved as 'audio_features.png' in the same directory.

Features Analyzed

This tool can be incredibly useful for voice analysis in various applications, including:

Remember that for accurate results, use high-quality audio recordings in a quiet environment. The audio should be in WAV format for best compatibility.

Download Full Source Code