Last active
May 19, 2020 06:57
-
-
Save hvrauhal/aed7969d05688b3d0baf486f0f16887a to your computer and use it in GitHub Desktop.
Create OpenTX Taranis sound files with MacOS say command to replace the ones on the card
This file contains 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
#!/usr/bin/env python3 | |
import argparse | |
import csv | |
import subprocess | |
from pathlib import Path | |
def create_sounds(sdcard_path: Path, voice: str, lang: str): | |
path_to_system = sdcard_path / 'SOUNDS' / lang / 'SYSTEM' | |
with (next(path_to_system.glob('*-taranis.csv')).open(newline='')) as csvfile: | |
reader = csv.reader(csvfile, delimiter=';') | |
for path, filename, content_to_say in reader: | |
out_filename = sdcard_path / path / filename | |
print(f'{out_filename} - {content_to_say}') | |
say_cmd = ['say', '-v', voice, '--file-format=WAVE', '-o', str(out_filename), '--data-format=LEI16@32000', | |
content_to_say] | |
subprocess.check_call(say_cmd) | |
def main(): | |
parser = argparse.ArgumentParser( | |
description='Create Taranis sound files with MacOS say command to replace the ones on the card' | |
) | |
parser.add_argument('sdcard_path', | |
type=Path, | |
help='The path to the target sdcard') | |
parser.add_argument('-v', | |
'--voice', | |
default='Ava', | |
help='The voice to pass to say') | |
parser.add_argument('-l', | |
'--lang', | |
default='en', | |
help='The lang to process') | |
args = parser.parse_args() | |
create_sounds(args.sdcard_path, args.voice, args.lang) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment