{"id":20581713,"url":"https://github.com/rhasspy/piper-sample-generator","last_synced_at":"2025-08-05T09:28:58.456Z","repository":{"id":166526575,"uuid":"642029941","full_name":"rhasspy/piper-sample-generator","owner":"rhasspy","description":"Generate samples using Piper to train wake word models","archived":false,"fork":false,"pushed_at":"2024-03-04T17:40:42.000Z","size":1074,"stargazers_count":31,"open_issues_count":6,"forks_count":27,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-14T19:58:57.857Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rhasspy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-17T17:03:32.000Z","updated_at":"2025-04-13T10:51:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"33415861-9bcc-4eb9-9484-99d4fe76ab41","html_url":"https://github.com/rhasspy/piper-sample-generator","commit_stats":null,"previous_names":["rhasspy/piper-sample-generator"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/rhasspy/piper-sample-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhasspy%2Fpiper-sample-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhasspy%2Fpiper-sample-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhasspy%2Fpiper-sample-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhasspy%2Fpiper-sample-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rhasspy","download_url":"https://codeload.github.com/rhasspy/piper-sample-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhasspy%2Fpiper-sample-generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268871302,"owners_count":24321252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-05T02:00:12.334Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T06:30:21.834Z","updated_at":"2025-08-05T09:28:58.408Z","avatar_url":"https://github.com/rhasspy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Piper Sample Generator\n\nGenerates samples using [Piper](https://github.com/rhasspy/piper/) for training a wake word system like [openWakeWord](https://github.com/dscripka/openWakeWord).\n\nAvailable models:\n\n* [English](https://github.com/rhasspy/piper-sample-generator/releases/download/v2.0.0/en_US-libritts_r-medium.pt)\n* [French](https://github.com/rhasspy/piper-sample-generator/releases/download/v2.0.0/fr_FR-mls-medium.pt)\n* [German](https://github.com/rhasspy/piper-sample-generator/releases/download/v2.0.0/de_DE-mls-medium.pt)\n* [Dutch](https://github.com/rhasspy/piper-sample-generator/releases/download/v2.0.0/nl_NL-mls-medium.pt)\n\n\n## Install\n\nCreate a virtual environment and install the requirements:\n\n``` sh\ngit clone https://github.com/rhasspy/piper-sample-generator.git\ncd piper-sample-generator/\n\npython3 -m venv .venv\nsource .venv/bin/activate\npython3 -m pip install --upgrade pip\npython3 -m pip install -r requirements.txt\n```\n\nDownload the LibriTTS-R generator (exported from [checkpoint](https://huggingface.co/datasets/rhasspy/piper-checkpoints/tree/main/en/en_US/libritts_r/medium)):\n\n``` sh\nwget -O models/en-us-libritts-high.pt 'https://github.com/rhasspy/piper-sample-generator/releases/download/v2.0.0/en_US-libritts_r-medium.pt'\n```\n\nSee links above for models for other languages.\n\n## Run\n\nGenerate a small set of samples with the CLI:\n\n``` sh\npython3 generate_samples.py 'okay, piper.' --max-samples 10 --output-dir okay_piper/\n```\n\nCheck the `okay_piper/` directory for 10 WAV files (named `0.wav` to `9.wav`).\n\nGeneration can be much faster and more efficient if you have a GPU available and PyTorch is configured to use it. In this case, increase the batch size:\n\n``` sh\npython3 generate_samples.py 'okay, piper.' --max-samples 100 --batch-size 10 --output-dir okay_piper/\n```\n\nOn an NVidia 2080 Ti with 11GB, a batch size of 100 was possible (generating approximately 100 samples per second).\n\nSetting `--max-speakers` to a value less than 904 (the number of speakers LibriTTS) is recommended. Because very few samples of later speakers were in the original dataset, using them can cause audio artifacts.\n\nSee `--help` for more options, including adjust the `--length-scales` (speaking speeds) and `--slerp-weights` (speaker blending) which are cycled per batch.\n\nAlternatively, you can import the generate function into another Python script:\n\n```python\nfrom generate_samples import generate_samples  # make sure to add this to your Python path as needed\n\ngenerate_samples(text = [\"okay, piper\"], max_samples = 100, output_dir = output_dir, batch_size=10)\n```\n\nThere are some additional arguments available when importing the function directly, see the docstring of `generate_sample` for more information.\n\n### Augmentation\n\nOnce you have samples generating, you can augment them using [audiomentation](https://iver56.github.io/audiomentations/):\n\n``` sh\npython3 augment.py --sample-rate 16000 okay_piper/ okay_piper_augmented/\n```\n\nThis will do several things to each sample:\n\n1. Randomly decrease the volume\n    * The original samples are normalized, so different volume levels are needed\n2. Randomly [apply an impulse response](https://iver56.github.io/audiomentations/waveform_transforms/apply_impulse_response/) using the files in `impulses/`\n    * Change the acoustics of the sample to sound like the speaker was in a room with echo or using a poor quality microphone\n3. Resample to 16Khz for training (e.g., [openWakeWord](https://github.com/dscripka/openWakeWord))\n\n\n## Short Phrases\n\nModels that were trained on audio books tend to perform poorly when speaking short phrases or single words.\nThe French, German, and Dutch models trained from the [MLS](http://openslr.org/94/) have this problem.\n\nThe problem can be mitigated by repeating the phrase over and over, and then clipping out a single sample.\nTo do this automatically, follow these steps:\n\n1. Ensure your short phrase ends with a comma (`\u003cphrase\u003e,`)\n2. Lower the noise settings with `--noise-scales 0.333` and `--noise-scale-ws 0.333`\n3. Use `--min-phoneme-count 300` (the value 300 was determined empirically and may be less for some models)\n\nFor example:\n\n``` sh\npython3 generate_samples.py \\\n    'framboise,' \\\n    --model models/fr_FR-mls-medium.pt \\\n    --noise-scales 0.333 \\\n    --noise-scale-ws 0.333 \\\n    --min-phoneme-count 300 \n    --max-samples 1 \\\n    --output-dir . \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhasspy%2Fpiper-sample-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frhasspy%2Fpiper-sample-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhasspy%2Fpiper-sample-generator/lists"}