File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed
Fruit_Jam/Fruit_Jam_Spell_Jam Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change 11# SPDX-FileCopyrightText: 2025 Tim Cocks for Adafruit Industries
22# SPDX-License-Identifier: MIT
3+
4+ import os
35import sys
46import time
57import supervisor
1214
1315from launcher_config import LauncherConfig
1416
15- # If tts_local.py exists, use that instead of tts_aws.py
16- try :
17+ # choose AWS TTS engine if AWS credentials are set in environment variables
18+ if os .getenv ("AWS_ACCESS_KEY" ) is not None and os .getenv ("AWS_SECRET_KEY" ) is not None :
19+ from tts_aws import WordFetcherTTS
20+ else :
1721 # tts_local defines WordFetcherTTS for TTS engine running on local network server
1822 from tts_local import WordFetcherTTS
19- except ImportError :
20- from tts_aws import WordFetcherTTS
2123
2224# read the user settings
2325launcher_config = LauncherConfig ()
Original file line number Diff line number Diff line change 11# SPDX-FileCopyrightText: 2025 RetiredWizard
22# SPDX-License-Identifier: MIT
33
4+ """
5+ Kani TTS engine for Fruit Jam Spell Jam. Install and run the kani-tts AI server on your
6+ local network following the instructions at: https://github.com/nineninesix-ai/kani-tts
7+
8+ The server.py script from the kani-tts repo needs to be modified to create 16bit WAV files
9+ instead of the default 32bit WAV files. Change the following lines in server.py
10+
11+ # Convert to WAV bytes
12+ wav_buffer = io.BytesIO()
13+ wav_write(wav_buffer, 22050, full_audio)
14+ wav_buffer.seek(0)
15+ to:
16+ # Convert float32 audio (-1.0 to 1.0) to 16-bit PCM
17+ audio_int16 = np.clip(full_audio, -1.0, 1.0)
18+ audio_int16 = (audio_int16 * 32767).astype(np.int16)
19+
20+ # Write as 16-bit WAV
21+ wav_buffer = io.BytesIO()
22+ wav_write(wav_buffer, 22050, audio_int16)
23+ wav_buffer.seek(0)
24+
25+ Then configure the server endpoint in launcher.conf.json, e.g.:
26+ "spell_jam": {
27+ "tts_server_endpoint": "http://myserver.local:8000"
28+ }
29+ """
30+
431# tts_kani.py
532import json
633import adafruit_connection_manager
You can’t perform that action at this time.
0 commit comments