Skip to main content

A library for analysis and synthesis of Indian classical music

Project description

Bhargava Swara

A Python library for analyzing and visualizing Indian classical music, including raga, tala, tempo, tradition, ornaments, full analysis, and mel-frequency spectrograms.

Prerequisites

  • Gemini API Key:
    This library uses Google's Gemini API for music analysis. To obtain a key, follow these steps:

    1. Sign up for a Google Cloud account.
    2. Enable the Generative AI API in the Google Cloud Console.
    3. Create an API key in the "Credentials" section.
      Refer to Google's Generative AI Docs for detailed instructions.
  • Audio Files:
    Supported formats include WAV and MP3 for spectrogram generation.

Installation

Install the library using pip:

pip install bhargava_swara

Usage

Music Analysis

Analyze various aspects of Indian classical music using the Gemini API.

from bhargava_swara import (
    analyze_raga,
    analyze_tala,
    analyze_tempo,
    analyze_tradition,
    analyze_ornaments,
    analyze_music_full
)

# Set your Gemini API key
api_key = "YOUR_API_KEY"
audio = "path/to/audio.wav"

# Individual analyses
print(f"Raga: {analyze_raga(audio, api_key)}")
print(f"Tala: {analyze_tala(audio, api_key)}")
print(f"Tempo: {analyze_tempo(audio, api_key)}")
print(f"Tradition: {analyze_tradition(audio, api_key)}")
print(f"Ornaments: {analyze_ornaments(audio, api_key)}")

# Full analysis
print(f"Full Analysis:\n{analyze_music_full(audio, api_key)}")

Mel-Frequency Spectrogram Generation

Generate a mel-frequency spectrogram to visualize the frequency content of an audio file over time.

from bhargava_swara import generate_mel_spectrogram

# Define input and output paths
audio = "path/to/audio.wav"
output = "path/to/output_mel_spectrogram.png"

# Generate the spectrogram
generate_mel_spectrogram(audio, output, n_mels=128, fmax=8000)
print("Mel spectrogram generated successfully!")

Parameters:

  • audio: Path to the input audio file (e.g., WAV or MP3).
  • output: Path to save the PNG file (e.g., "spectrogram.png").
  • n_mels: Number of mel bands (default: 128).
  • fmax: Maximum frequency in Hz (default: 8000).

Dependencies

  • google-generativeai>=0.1.0
  • librosa>=0.10.0
  • matplotlib>=3.7.0
  • numpy>=1.24.0

Contributing

Contributions are welcome! Please submit a pull request or open an issue on the GitHub repository (if available).

License

This library is licensed under the MIT License. See the LICENSE file for details.


Change Log
==========

0.0.1 (26/03/2025)
-------------------
- First Release

===========

0.0.2 (27/03/2025)
-------------------
- Fixed missing module files in package

0.0.3 (27/03/2025)
-------------------
- Fixed ornaments detection file

0.0.4 (27/03/2025)
-------------------
- Fixed real time full analysis file

0.0.5 (27/03/2025)
-------------------
- Added mel-frequency spectogram generation

0.0.6 (27/03/2025)
-------------------
- seaborn included. README.txt updated

0.0.7 (27/03/2025)
-------------------
- mel-frequency spectogram issue resolved. README.md is created

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bhargava_swara-0.0.7.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bhargava_swara-0.0.7-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file bhargava_swara-0.0.7.tar.gz.

File metadata

  • Download URL: bhargava_swara-0.0.7.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for bhargava_swara-0.0.7.tar.gz
Algorithm Hash digest
SHA256 dcc96466239b03b5188fa023205e6dcf09b0c88440ee07a218c929f3f89a947a
MD5 10b94897231390de21f9e9e530cf3a7e
BLAKE2b-256 cafec91521fe01f6511ae2c8b100001da12e8ec90eb0810aa2d7bc69568aab16

See more details on using hashes here.

File details

Details for the file bhargava_swara-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: bhargava_swara-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for bhargava_swara-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 73f170117f247c2802311c9a49070910978f98bdad471ac5b6658b5b4130cc39
MD5 822c36ff0382c9c64504f74d26510f94
BLAKE2b-256 0e350b74cf863ab4292ceae6b58a41fa2f254cce420ca8a3a6abb69ada4aff4c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page