Skip to content

Latest commit

 

History

History
171 lines (120 loc) · 4.6 KB

cookbook.md

File metadata and controls

171 lines (120 loc) · 4.6 KB

Cookbook

Task-first recipes. Every example runs on the mock backend if you have no weights installed — the shapes are real even when the audio is not.

Clean up a noisy recording

openspeech run -i raw.wav -r "remove the background noise and reverb" -o clean.wav

Mentioning only one problem selects the narrower instruction, which is usually what you want:

openspeech run -i raw.wav -r "just take the room echo off" -o clean.wav
#  -> enhance_speech(cleanup_mode='dereverb')

Master to a delivery target

openspeech run -i episode.wav -r "normalise to -16 LUFS" -o master.wav        # podcast
openspeech run -i episode.wav -r "normalise to EBU R128" -o master.wav        # -23 LUFS
openspeech measure master.wav                                                 # verify

This runs entirely in local DSP: exact, instant, no GPU time.

Do several things at once

openspeech run -i interview.wav \
  -r "clean up the noise, keep only the second speaker, calm the delivery, and master to -16 LUFS" \
  -o out.wav

Check how it will be read before spending model time:

openspeech plan "clean up the noise, keep only the second speaker, calm the delivery, master to -16 LUFS"

Isolate one speaker

By talking order, for short clips:

openspeech run -i two-speakers.wav -r "keep only the second speaker" -o guest.wav

For anything longer than the context window, identify them by what they say — that is stable across chunks, where talking order is not:

openspeech run -i interview.wav \
  -r 'keep only the speaker who says "thanks for having me"' -o guest.wav

Edit words

openspeech run -i take.wav \
  -r "replace 'quarterly revenue' with 'annual revenue'" -o fixed.wav

Quotes are required — they are what distinguishes a word replacement from change the emotion to happy.

Word-level edits cannot be split across chunks, so trim to the region containing the edit first:

from openspeech import process, read_audio, write_audio
from openspeech.audio import Audio

full = read_audio("long-take.wav")
region = full.slice_seconds(72.0, 80.0)                    # the sentence to fix
fixed = process(region, "replace 'quarterly' with 'annual'").audio

write_audio("patched.wav", Audio.concat([
    full.slice_seconds(0, 72.0), fixed, full.slice_seconds(80.0, None),
]))

Text to speech

openspeech run -r 'say "Welcome back to the show" in a warm announcer voice' -o intro.wav

In an existing voice, from a reference recording:

openspeech run -i host-sample.wav \
  -r 'say "and we are back after the break" with the same voice' -o bridge.wav

Remove breaths and filler

openspeech run -i vo.wav -r "strip the breaths" -o vo-clean.wav
openspeech run -i vo.wav -r "remove the ums" -o vo-clean.wav

Fix a bad line

openspeech run -i call.wav -r "it sounds like a phone call, fix it" -o wide.wav
openspeech run -i muddy.wav -r "it's muffled" -o clear.wav

Work in Chinese

Requests and instructions are both bilingual:

openspeech plan "去掉噪声和混响,然后把语速调慢一点,同时把情感变成平静"
 1. [model] enhance_speech(cleanup_mode='denoise_dereverb')
 2. [model] emotion_edit(emotion='calm')
 3. [model] speed_edit(speed_multiplier=0.75)

Batch a directory

from pathlib import Path
from openspeech import Pipeline, plan_request, read_audio, write_audio
from openspeech.engine import CachedEngine, create_engine

engine = CachedEngine(create_engine("auto"))   # load the model once
plan = plan_request("remove the noise and normalise to -16 LUFS")
pipeline = Pipeline(engine)

for source in Path("raw").glob("*.wav"):
    result = pipeline.run(plan, read_audio(source))
    write_audio(Path("clean") / source.name, result.audio)
    print(f"{source.name}: {result.verdict}")

print(engine.stats.as_dict())

Planning once and reusing the plan avoids re-parsing, and the cache means an interrupted batch resumes almost free.

Check a result

openspeech measure out.wav
openspeech run ... --report report.json     # full per-step, per-chunk detail
import json
report = json.load(open("report.json"))
for step in report["steps"]:
    print(step["op"], step["verdict"], step["repairs"])

Build an episode

See studio.md.

openspeech studio episode.json -o build/

Check your installation

openspeech doctor

Reports which optional extras are installed, whether an AuK checkpoint was found, and which backend will actually run. If it says mock, you are not getting model output.