A professional library that transforms code into sound. Build synthesizers, compose melodies, and design audio with unprecedented control.
pip install sprechstimme
Sprechstimme is a professional-grade Python library that bridges the gap between code and music. Whether you're a musician exploring algorithmic composition or a developer building audio applications, Sprechstimme provides the tools you need.
From simple sine waves to complex FM synthesis, from single notes to multi-track compositions, Sprechstimme handles it all with an elegant, Pythonic API.
17+ waveform types including classic oscillators, FM synthesis, wavetable morphing, and physical modeling.
Studio-quality filters and effects for shaping your sound.
Build complex arrangements with precise timing control.
Understand your audio with professional analysis tools.
Pre-configured instruments ready to use: piano, strings, brass, bass, leads, pads, and experimental sounds.
import sprechstimme as sp
# Create a synthesizer
sp.new('synth')
# Play a note
sp.play('synth', 'A4', duration=1.0)
# Play a chord
sp.play('synth', ['C4', 'E4', 'G4'], duration=2.0)
import sprechstimme as sp
from functools import partial
# Create custom synthesizer
sp.new('lead')
sp.create(
'lead',
wavetype=sp.waves.fm,
filters=[
partial(sp.filters.moog_ladder, cutoff=2000, resonance=0.7),
partial(sp.filters.reverb, room_size=0.8)
],
envelope={
'attack': 0.01,
'decay': 0.2,
'sustain': 0.6,
'release': 0.5
}
)
sp.play('lead', 'C5', duration=3.0)
import sprechstimme as sp
# Load presets
sp.presets.load('piano')
sp.presets.load('bass')
# Create song
song = sp.Song(bpm=120)
# Add piano chords
song.add_chord('piano_track', 'piano', 'C4', beat_position=0, duration=4)
song.add_chord('piano_track', 'piano', 'F4', beat_position=4, duration=4)
song.add_chord('piano_track', 'piano', 'G4', beat_position=8, duration=4)
# Add bass line
for i, note in enumerate(['C2', 'C2', 'F2', 'F2', 'G2', 'G2']):
song.add('bass_track', 'bass', note, beat_position=i*2, duration=1.5)
# Export
song.export('my_song.wav')
import sprechstimme as sp
import numpy as np
# Generate audio
sp.new('synth')
audio = sp.generate('synth', 'A4', duration=2.0)
# Analyze pitch
pitch, confidence = sp.analysis.detect_pitch(audio)
print(f'Pitch: {pitch:.2f} Hz ({confidence:.1%} confidence)')
# Get spectrum
spectrum = sp.analysis.fft(audio)
freqs, mags = sp.analysis.get_spectrum(spectrum)
# Find peaks
peaks = sp.analysis.find_peaks(mags, threshold=0.5)
print(f'Spectral peaks at: {freqs[peaks][:5]} Hz')
# Detect tempo
bpm = sp.analysis.detect_tempo(audio)
print(f'Tempo: {bpm:.1f} BPM')
Experiment with Sprechstimme directly in your browser
Full-featured code editor with real-time audio synthesis running directly in your browser. No installation required!
Install the complete Sprechstimme library locally for advanced features, file export, and integration with your projects.
Copy this into any Python environment to get started:
# Install and import
import os
os.system('pip install sprechstimme')
import sprechstimme as sp
# Create your first sound
sp.new('synth')
sp.play('synth', ['C4', 'E4', 'G4'], duration=2.0)
Explore the power of Sprechstimme with live examples
See different synthesis methods in action. Select a waveform to visualize its shape:
Create harmonic progressions with automatic voice leading.
sp.presets.load('piano')
song = sp.Song(bpm=90)
for chord in ['Cmaj7', 'Am7', 'Fmaj7', 'G7']:
song.add_chord('piano', chord, duration=4)
Frequency modulation creates metallic, bell-like timbres.
sp.new('bell')
sp.create('bell',
wavetype=sp.waves.fm,
mod_ratio=3.5,
mod_index=12,
envelope={'decay': 2.0}
)
Classic analog-style filter with resonance control.
sp.new('bass')
sp.apply_filter('bass',
sp.filters.moog_ladder,
cutoff=500,
resonance=0.9
)
Physical modeling algorithm for plucked string instruments.
sp.new('guitar')
sp.create('guitar',
wavetype=sp.waves.karplus_strong,
damping=0.998
)
sp.play('guitar', 'E2', duration=3.0)
Add depth and space to any sound with reverb and delay.
sp.apply_filter('synth',
sp.filters.reverb,
room_size=0.9,
damping=0.5
)
sp.apply_filter('synth', sp.filters.delay)
Analyze frequency content and detect musical features.
audio = sp.generate('synth', 'A4')
spectrum = sp.analysis.fft(audio)
pitch = sp.analysis.detect_pitch(audio)
print(f"Detected: {pitch} Hz")
Smoothly morph between different waveforms over time.
sp.new('morph')
sp.create('morph',
wavetype=sp.waves.wavetable,
tables=[sp.waves.sine, sp.waves.square],
morph_position=0.5
)
Export complete songs with multiple instruments to WAV.
song = sp.Song(bpm=128)
song.add_track('drums', 'kick', ...)
song.add_track('bass', 'bass', ...)
song.export('output.wav', quality='high')