-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add sound analysis tools and visualization modules #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| name: Streamlit App CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Python 3.10 | ||
| uses: actions/setup-python@v3 | ||
| with: | ||
| python-version: "3.10" | ||
|
|
||
| - name: Install system dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y ffmpeg | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install flake8 pytest | ||
| if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
|
|
||
| - name: Lint with flake8 | ||
| run: | | ||
| # stop the build if there are Python syntax errors or undefined names | ||
| flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
| # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
| flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
|
|
||
| - name: Test Streamlit Config | ||
| run: | | ||
| streamlit config show |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| [theme] | ||
| base = "dark" | ||
| primaryColor = "#6366f1" | ||
| # Removing hardcoded backgrounds to allow native toggling | ||
| # backgroundColor = "#0e1117" | ||
| # secondaryBackgroundColor = "#1e1e2e" | ||
| # textColor = "#fafafa" | ||
| font = "sans serif" | ||
|
|
||
| [server] | ||
| maxUploadSize = 50 | ||
| enableXsrfProtection = true | ||
|
|
||
| [browser] | ||
| gatherUsageStats = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,82 @@ | ||
| # Python Sound Wave Analysis | ||
| # 🌊 Sound Wave Analysis | ||
|
|
||
| A simple open-source project for analyzing and visualizing sound waves using Python. Clean, lightweight, and beginner-friendly. | ||
| A professional, web-based tool for analyzing and visualizing audio files. Built with **Streamlit** and **Plotly**, this application provides physics-grade analysis of sound waves, supporting WAV, MP3, and FLAC formats. | ||
|
|
||
| --- | ||
|  | ||
| *(Note: Replace with actual screenshot path once pushed)* | ||
|
|
||
| ## License | ||
| This project is licensed under the **Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)** license. | ||
| You may use, share, and modify the project **with attribution**, but **not for commercial purposes**. | ||
| ## 🚀 Features | ||
|
|
||
| [](https://doi.org/10.5281/zenodo.17607793) | ||
| ### 📊 Professional Visualization | ||
| - **Waveform**: Interactive time-domain display. | ||
| - **Frequency Spectrum**: Audacity-style spectrum analysis with log scale frequency and dB. | ||
| - **Spectrogram**: Time-frequency intensity heatmap. | ||
| - **Power Spectral Density (PSD)**: Energy distribution across frequencies. | ||
| - **Phase Response**: Phase angle vs. frequency. | ||
| - **Amplitude Histogram**: Distribution of signal amplitudes. | ||
|
|
||
| Full license text is available in the `LICENSE` file. | ||
| ### 🔬 Detailed Analysis | ||
| - **Audio Metrics**: Sample rate, duration, channels, RMS dB, dynamic range. | ||
| - **Harmonic Detection**: Identifies fundamental frequency and up to 5 overtones. | ||
| - **Speed of Sound Calculator**: Real-time calculator for various media (Air, Water, Steel, etc.) with temperature adjustment. | ||
|
|
||
| --- | ||
| ### 🛠️ Key Capabilities | ||
| - **Multi-Format Support**: Upload WAV, MP3, or FLAC files (auto-converted). | ||
| - **Audio Playback**: Listen to your audio directly in the browser. | ||
| - **Interactive UI**: Native Dark/Light mode support (toggles via Streamlit Settings). | ||
| - **Export Options**: Download analysis data as CSV or a text summary. | ||
|
|
||
| ## Getting Started | ||
| ## 🛠️ Tech Stack | ||
|
|
||
| Clone the repository: | ||
| - **Frontend**: [Streamlit](https://streamlit.io/) | ||
| - **Visualization**: [Plotly](https://plotly.com/python/) | ||
| - **Audio Processing**: [NumPy](https://numpy.org/), [SciPy](https://scipy.org/), [Pydub](https://github.com/jiaaro/pydub) | ||
| - **Deployment**: Streamlit Cloud | ||
|
|
||
| ```bash | ||
| git clone https://github.com/TorresjDev/Python-Sound-Wave-Analysis.git | ||
| ```` | ||
| ## 📦 Installation & Local Development | ||
|
|
||
| Install dependencies: | ||
| 1. **Clone the repository:** | ||
| ```bash | ||
| git clone https://github.com/TorresjDev/Python-Sound-Wave-Analysis.git | ||
| cd Python-Sound-Wave-Analysis | ||
| ``` | ||
|
|
||
| ```bash | ||
| pip install -r requirements.txt | ||
| ``` | ||
| 2. **Install dependencies:** | ||
| ```bash | ||
| pip install -r requirements.txt | ||
| ``` | ||
| *Note: For MP3/FLAC support, ensure you have [ffmpeg](https://ffmpeg.org/) installed on your system.* | ||
|
|
||
| Run the program: | ||
| 3. **Run the app:** | ||
| ```bash | ||
| streamlit run streamlit_app.py | ||
| ``` | ||
|
|
||
| ```bash | ||
| python main.py | ||
| ``` | ||
| 4. **Open in browser:** | ||
| The app will automatically open at `http://localhost:8501`. | ||
|
|
||
| --- | ||
| ## ☁️ Deployment | ||
|
|
||
| ### Deploying to Streamlit Cloud | ||
|
|
||
| 1. Push your code to GitHub. | ||
| 2. Sign in to [Streamlit Cloud](https://share.streamlit.io/). | ||
| 3. Click **"New App"**. | ||
| 4. Select your repository (`TorresjDev/Python-Sound-Wave-Analysis`), branch (`main`), and main file (`streamlit_app.py`). | ||
| 5. Click **"Deploy"**. | ||
|
|
||
| ## Author | ||
| Streamlit Cloud will automatically detect `packages.txt` (if added for ffmpeg) and `requirements.txt` to install dependencies. | ||
|
|
||
| Created by **Jesus Torres (TorresjDev)** | ||
| ## 🧪 CI/CD | ||
|
|
||
| This project uses **GitHub Actions** for continuous integration: | ||
| - **Python Linting**: Checks for syntax errors and coding standards. | ||
| - **Dependency Test**: Verifies that `requirements.txt` installs correctly. | ||
| - **Streamlit Config Check**: Ensures the app configuration is valid. | ||
|
|
||
| ## 📜 License | ||
|
|
||
| This project is licensed under the CC BY-NC 4.0 License. | ||
|
|
||
| --- | ||
| **Created by [TorresjDev](https://github.com/TorresjDev)** |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| Sound Wave Analysis - Clean and Modular | ||
|
|
||
| A user-friendly tool for analyzing WAV files with visualization. | ||
|
|
||
| Author: TorresjDev | ||
| License: MIT | ||
| """ | ||
|
|
||
| import os | ||
| from sound_analysis.analyzer import perform_complete_analysis | ||
| from sound_analysis.tools import select_wav_file, get_analysis_options | ||
|
|
||
|
|
||
| def main(): | ||
| """Main function - clean and modular.""" | ||
| print("🌊 Welcome to Sound Wave Analysis!") | ||
| print("=" * 40) | ||
|
|
||
| # Let user select a WAV file | ||
| selected_file = select_wav_file() | ||
|
|
||
| if selected_file: | ||
| print(f"\n🎯 Analyzing: {os.path.basename(selected_file)}") | ||
|
|
||
| # Get analysis options | ||
| options = get_analysis_options() | ||
|
|
||
| # Perform analysis using the analyzer module | ||
| perform_complete_analysis( | ||
| selected_file, | ||
| show_plots=options["show_plots"], | ||
| save_figures=options["save_figures"] | ||
| ) | ||
| else: | ||
| print("\n👋 Goodbye!") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ffmpeg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # Core dependencies for Sound Wave Analysis | ||
| numpy>=1.21.0 | ||
| matplotlib>=3.5.0 | ||
| scipy>=1.7.0 | ||
|
|
||
| # Enhanced user interface (CLI) | ||
| keyboard>=0.13.5 | ||
|
|
||
| # Streamlit Web App | ||
| streamlit>=1.29.0 | ||
| plotly>=5.18.0 | ||
|
|
||
| # Audio format support (MP3, FLAC) | ||
| pydub>=0.25.1 | ||
|
|
||
| # Development dependencies (optional) | ||
| # pytest>=6.0.0 | ||
| # black>=21.0.0 | ||
| # flake8>=3.9.0 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,162 @@ | ||||||
| """ | ||||||
| Sound Analysis Analyzer | ||||||
|
|
||||||
| Core analysis functions for processing WAV files. | ||||||
| """ | ||||||
|
|
||||||
| import os | ||||||
| import wave | ||||||
| import numpy as np | ||||||
| from .tools import wave_to_db, wave_to_db_rms, detect_db_range, list_wav_files | ||||||
| from .visualization import plot_waveform, plot_spectrogram, plot_combined_analysis | ||||||
|
||||||
| from .visualization import plot_waveform, plot_spectrogram, plot_combined_analysis | |
| from .visualization import plot_waveform, plot_spectrogram |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'list_wav_files' is not used.