-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathpython_wizard
More file actions
executable file
·95 lines (82 loc) · 2.63 KB
/
python_wizard
File metadata and controls
executable file
·95 lines (82 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python3
import logging
import re
import os
import sys
from lpcplayer.tables import tables
'''
Command line application for processing WAV files into LPC data
for use with TMS5220 (emulators)
'''
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--unvoicedThreshold",
help="Unvoiced frame threshold",
action="store",
default=0.3,
type=float)
parser.add_argument("-w", "--windowWidth",
help="Window width in frames",
action="store",
default=2,
type=int)
parser.add_argument("-U", "--normalizeUnvoicedRMS",
help="Normalize unvoiced frame RMS",
action="store_true")
parser.add_argument("-V", "--normalizeVoicedRMS",
help="Normalize voiced frame RMS",
action="store_true")
parser.add_argument("-S", "--includeExplicitStopFrame",
help="Create explicit stop frame (needed e.g. for Talkie)",
action="store_true")
parser.add_argument("-p", "--preEmphasis",
help="Pre emphasize sound to improve quality of translation",
action="store_true")
parser.add_argument("-a", "--preEmphasisAlpha",
help="Emphasis coefficient",
type=float,
default=-0.9373)
parser.add_argument("-d", "--debug",
help="Enable (lots) of debug output",
action="store_true")
parser.add_argument("-r", "--pitchRange",
help="Comma separated range of available voice pitch in Hz. Default: 50,500",
default="50,500")
parser.add_argument("-F", "--frameRate",
default=25,
type=int)
parser.add_argument("-m", "--subMultipleThreshold",
help="sub-multiple threshold",
default=0.9,
type=float)
parser.add_argument("-f", "--outputFormat",
help="Output file format",
choices=["arduino", "C", "hex", "python"],
default="hex")
parser.add_argument("-T", "--tablesVariant",
help="Tables variant",
choices=tables.keys(),
default="tms5220")
parser.add_argument("filename",
help="File name of a .wav file to be processed",
action="store")
args = parser.parse_args()
if args.debug:
logging.basicConfig(level=logging.DEBUG)
from pywizard.userSettings import settings
settings.import_from_argparse(args)
from pywizard.FrameDataBinaryEncoder import BitPacker
from pywizard.Processor import Processor
from pywizard.Buffer import Buffer
#settings.import_from_argparse(args)
from pywizard.CodingTable import CodingTable
b = Buffer.fromWave(args.filename)
if b is None:
sys.exit()
x=Processor(b, args.tablesVariant)
result = BitPacker.pack(x)
new_varname = os.path.basename(args.filename)
new_varname = os.path.splitext(new_varname)[0]
if re.match("^[^A-Za-z_]", new_varname):
new_varname = "_"+new_varname
print(result.replace("FILENAME", new_varname))