ptwz / python_wizard Goto Github PK
View Code? Open in Web Editor NEWCommand line LPC analysis tool to generate bitstreams for the Texas Instruments TMS5220 chip
License: MIT License
Command line LPC analysis tool to generate bitstreams for the Texas Instruments TMS5220 chip
License: MIT License
I was able to use this program to convert a few audio files to LPC data, and I noticed the README.md mentions a playback feature was added, but I can't seem to find a way to activate it in the GUI, how would one go about playing back the LPC data?
Hi, can you make a quick guide on how to execute this files for noobs?
Edit: I downloaded thonny python and added the scipy package, then runned the file python_wizard_gui ( as said by christurnerchris in the issue #18). But still i can't convert the .wav files to LPC streams.
I got this error message in Thonny:
%Run python_wizard_gui
0 1.1538461538461537
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\yanvp\AppData\Roaming\Python\Python310\site-packages\scipy_init_.py", line 150, in getattr
return globals()[name]
KeyError: 'array'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\yanvp\AppData\Local\Programs\Thonny\lib\tkinter_init_.py", line 1921, in call
return self.func(*args)
File "C:\Users\yanvp\AppData\Local\Programs\Thonny\lib\tkinter_init_.py", line 839, in callit
func(*args)
File "C:\Users\yanvp\Desktop\python_wizard-master\python_wizard_gui", line 304, in repeatedly
b = Buffer.fromWave(self.filename)
File "C:\Users\yanvp\Desktop\python_wizard-master\pywizard\Buffer.py", line 31, in fromWave
d2 = sp.array(data, 'float')
File "C:\Users\yanvp\AppData\Roaming\Python\Python310\site-packages\scipy_init.py", line 152, in getattr
raise AttributeError(
AttributeError: Module 'scipy' has no attribute 'array'
This is my UI:
This is the file I want to convert:
https://drive.google.com/drive/folders/1eITYrZ8G5vy2q2sdLpcDv9ZlD8DFJGni?usp=drive_link
Got python_wizard_gui.py to run in pyroid3 on Android
I don't know how to put the -f arduino on the end but it has defaulted to Arduino anyway!
How do i Input the wav file
Hi @ptwz
Amazing code btw !
I tried loading the application, i have python 3.9 installed along with spicy. But i keep getting this error when i run setup.py
C:\Users"username"\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\distutils_patch.py:25: UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
warnings.warn(
Any guidance is much appreciated
Thanks
(If you want to try it with my files, they are here : audio files)
when processing some audio files I have a warning like :
/Users/***pywizard/Buffer.py:99: RuntimeWarning: invalid value encountered in double_scalars
coefficients[lag] = s / (rmsBeginning * rmsEnding)
when running
python python_wizard.py -u 0.3 -w 2 -S -p -a -0.9375 -m 0.9 -f hex arcb.wav
but the encoding works
sometimes Its also give me this error : (with the file wftatc.wav)
/Users/***pywizard/Buffer.py:99: RuntimeWarning: invalid value encountered in double_scalars
coefficients[lag] = s / (rmsBeginning * rmsEnding)
Traceback (most recent call last):
File "python_wizard.py", line 73, in <module>
x=Processor(b)
File "/Users/***pywizard/Processor.py", line 27, in __init__
self.pitchTable = self.pitchTableForBuffer(self.pitchBuffer)
File "/Users/***pywizard/Processor.py", line 61, in pitchTableForBuffer
pitchTable[index] = PitchEstimator.pitchForPeriod(buf)
File "/Users/***pywizard/PitchEstimator.py", line 8, in pitchForPeriod
return cls(buf).estimate()
File "/Users/***pywizard/PitchEstimator.py", line 43, in estimate
subMultiplePeriod = int( sp.floor( (i+1) * estimate / maximumMultiple + .5) )
ValueError: cannot convert float NaN to integer
but here the encoding doen't work.
(these files works fine in BlueWizard)
I noticed that the sound produced with python_wizard are never as good as the one produced by BlueWizard with the same parameters.
Is this normal? I saw the commits in the cleanup branch. Are you working on this issue?
I love to use python_ward because I can batch process a text file, have each of the lines converted to wav (via Say), process them with python_wizard and then directly send the LPC stream to the Arduino via py_serial for an instant quality check.
I was struggling to get python_wizard to work as it was spitting out errors about RuntimeWarning: invalid value encountered in true_divide
on the 8kHz, 16bit signed wav file I was trying to read.
I eventually heavily trimmed it so there was no trailing quiet or silent part and that seems to have fixed it and produced output that (with -S
option) works in Talkie equivalent code. The results were almost too good, I need a more robotic voice!!
I'll put more details here as I discovered them, either -d
for debug or some fiddling around with pdb
showed a suspicious array full of zeros and maybe a few NaN
s.
It would be great if there were sample sample wavs together with their expected output in the repository. Those could even be part of some simple tests.
Got python_wizard_gui.py to run in pyroid3 on Android
You need to install the script library first
I don't know how to put the -f arduino on the end but it has defaulted to Arduino anyway!
It's not obvious what's going on with the current version if you accidentally feed it a stereo wave file:
Traceback (most recent call last):
File "/path/venv/bin/python_wizard", line 71, in <module>
b=Buffer.fromWave(args.filename)
File "/path/venv/lib/python3.X/site-packages/pywizard/Buffer.py", line 32, in fromWave
assert(max(d2) <= 1)
This issue may help others who search for what this output means.
then it is found by python editors as a python file
When I try to run python-wizard.py, I get this rather cryptic error code:
Traceback (most recent call last):
File "python_wizard.py", line 71, in <module>
b=Buffer.fromWave(args.filename)
File "C:\Users\laure\Documents\python_wizard-master\python_wizard-master\pywizard\Buffer.py", line 32, in fromWave
assert(max(d2) <= 1)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I don't know anything about this error, except that I have already seen this while using the numpy module.
I was converting my own numbers from 0 to 9. I know they already exist it was just a test. All converted but the number nine. I will try to attach it here but first here is the error I got:
Before the error I just tried to attach the wav file and it would not let me. Here is a drop box link to it:
https://www.dropbox.com/scl/fi/po3fjhaz8o53109iprrhn/Nine.wav?rlkey=fzpojpkuvc55ftupp92xe304n&dl=0
After you try it I will remove the link kbut for now it will be up there.
Note I tried this with python 3.11 and 3.8.9
I would rather not go back to 2.x if I don't need to.
Traceback (most recent call last):
File "C:\data\python_wizard\python_wizard", line 87, in
result = BitPacker.pack(x)
File "C:\data\python_wizard\pywizard\FrameDataBinaryEncoder.py", line 18, in pack
parametersList = [ x.parameters() for x in frameData ]
File "C:\data\python_wizard\pywizard\FrameDataBinaryEncoder.py", line 18, in
parametersList = [ x.parameters() for x in frameData ]
File "C:\data\python_wizard\pywizard\FrameData.py", line 37, in parameters
self._parameters = self.parametersWithTranslate(False)
File "C:\data\python_wizard\pywizard\FrameData.py", line 47, in parametersWithTranslate
parameters["kParameterGain"] = self.parameterizedValueForRMS(self.reflector.rms, translate=translate)
File "C:\data\python_wizard\pywizard\Reflector.py", line 76, in rms
return self.codingTable.rms[CodingTable.kStopFrameIndex - 1]
NameError: name 'CodingTable' is not defined
I am trying to run python python_wizard.py -f arduino fired.wav
but I get this error :
Traceback (most recent call last):
File "python_wizard.py", line 60, in
settings.import_from_argparse(args)
File "/Users//Downloads/python_wizard-master/backend.py", line 37, in import_from_argparse
self.import_from_dict(v)
File "/Users//Downloads/python_wizard-master/backend.py", line 46, in import_from_dict
self.setattr(key, type(self.getattribute(key))(input_dict[key]))
AttributeError: 'userSettings' object has no attribute 'filename'
I am on Mac with Python 2.7.11
I thought I had raised this as an issue, but it seems to have disappeared.
python3 /home/stephena/python_wizard/python_wizard -S -T tms5220 -f arduino you.wav2 > wavelpc.h
This is the original code in your original instructions, my file names.
But it overwrites the same file, each time you use it.
It should be
python3 /home/stephena/python_wizard/python_wizard -S -T tms5220 -f arduino you.wav2 >> wavelpc.h
which adds the lines to the existing file.
Secondly how do you run repeated command lines like this in python or shell script?
I have 43 wave files to process into one lpc file!
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\asrock\AppData\Local\Programs\Python\Python39\lib\tkinter_init_.py", line 1892, in call
return self.func(*args)
File "C:\Users\asrock\AppData\Local\Programs\Python\Python39\lib\tkinter_init_.py", line 814, in callit
func(*args)
File "C:\Software\python_wizard\python_wizard_gui", line 300, in _repeatedly
self._readback_table()
File "C:\Software\python_wizard\python_wizard_gui", line 285, in _readback_table
params = frame.parameters()
File "C:\Software\python_wizard\pywizard\FrameData.py", line 37, in parameters
self._parameters = self.parametersWithTranslate(False)
File "C:\Software\python_wizard\pywizard\FrameData.py", line 47, in parametersWithTranslate
parameters["kParameterGain"] = self.parameterizedValueForRMS(self.reflector.rms, translate=translate)
File "C:\Software\python_wizard\pywizard\Reflector.py", line 76, in rms
return self.codingTable.rms[CodingTable.kStopFrameIndex - 1]
NameError: name 'CodingTable' is not defined
When i try to run i get this error;
NameError: name 'CodingTable' is not defined
or longer version.
(work) C:\dev\python_wizard>python python_wizard -f arduino a.wav
C:\dev\python_wizard\pywizard\Reflector.py:53: RuntimeWarning: invalid value encountered in double_scalars
k[1] = -r[1] / r[0]
Traceback (most recent call last):
File "C:\dev\python_wizard\python_wizard", line 87, in
result = BitPacker.pack(x)
File "C:\dev\python_wizard\pywizard\FrameDataBinaryEncoder.py", line 18, in pack
parametersList = [ x.parameters() for x in frameData ]
File "C:\dev\python_wizard\pywizard\FrameDataBinaryEncoder.py", line 18, in
parametersList = [ x.parameters() for x in frameData ]
File "C:\dev\python_wizard\pywizard\FrameData.py", line 37, in parameters
self._parameters = self.parametersWithTranslate(False)
File "C:\dev\python_wizard\pywizard\FrameData.py", line 47, in parametersWithTranslate
parameters["kParameterGain"] = self.parameterizedValueForRMS(self.reflector.rms, translate=translate)
File "C:\dev\python_wizard\pywizard\Reflector.py", line 76, in rms
return self.codingTable.rms[CodingTable.kStopFrameIndex - 1]
NameError: name 'CodingTable' is not defined
I'm using it to generate my own sound files, but after I play it via arduino and Talkie library the sound if grabled at the end. What am I doing wrong?
Thanks a lot!
./python_wizard -V -p temp.wav -f arduino
/home/osboxes/.local/lib/python2.7/site-packages/numpy/lib/function_base.py:3183: RuntimeWarning: invalid value encountered in true_divide
c /= stddev[:, None]
/home/osboxes/.local/lib/python2.7/site-packages/numpy/lib/function_base.py:3184: RuntimeWarning: invalid value encountered in true_divide
c /= stddev[None, :]
const unsigned char temp[] PROGMEM = {0x00,0x00,0x04,0x78,0x36,0x5D,0x01,0x57,0x1B,0xA7,0xA0,0x52,0xD5,0xBC,0x9E,0xD4,0x82,0xC2,0x45,0xE3,0x7A,0x76,0x08,0xBC,0xB4,0xDC,0x95,0xD8,0x21,0xD0,0xCA,0xEB,0x86,0x62,0x8B,0x90,0xBA,0xEA,0x71,0x8C,0x85,0x12,0xAE,0xAB,0x3A,0xD5,0x92,0xF1,0xAA,0x10,0xF5,0xAA,0xDA,0xCD,0x6F,0x4C,0x25,0x26,0x67,0x2F,0x7F,0x48,0x13,0xAB,0x58,0x34,0x82,0x26,0xCD,0x3C,0xF2,0x71,0x0B,0x4B,0x70,0x67,0xEF,0xC9,0x2B,0xCC,0x31,0x5C,0xB3,0xE7,0xAC,0x30,0x87,0x34,0xEB,0x5A,0xBC,0x82,0xEC,0xCB,0xAD,0x7A,0x76,0x09,0x52,0x48,0xD3,0xEA,0xD0,0x24,0xF2,0x3E,0xD5,0xB3,0x48,0x03,0x08,0x60,0xCB,0x0C,0x13,0x04,0xD2,0x65,0xEE,0x8B,0x5D,0xA4,0xF5,0x16,0x5B,0x3C,0x32,0xB1,0xD4,0x5B,0x6C,0xFE,0xCA,0xC4,0x42,0xDD,0x98,0xF2,0x67,0x13,0x0B,0x75,0x6B,0xCA,0x9F,0x5D,0xAC,0xE4,0x8E,0x29,0x7F,0x0E,0xB1,0xD5,0x53,0xAC,0xF6,0x30,0x24,0x36,0x74,0x90,0xE5,0x2D,0x97,0xF9,0x1C,0xCA,0x99,0x75,0x43,0x1E,0x8B,0xA9,0xB4,0x35,0x2D,0x79,0x74,0xE9,0x3C,0xD6,0xB4,0xE4,0x59,0x55,0xF2,0x58,0x9B,0x92,0x67,0x55,0xC1,0x6B,0x8B,0x53,0x91,0x4D,0xBA,0x8E,0xCE,0x74,0x65,0x72,0x61,0xD6,0x5A,0x92,0x55,0xC1,0x9A,0x6A,0x49,0x48,0x64,0x70,0x63,0x16,0xEE,0xB1,0x00,0x00,0x00,0x00};
Adding 0xFF at the end sometimes helps, but not with every sample. I guess, this is encoding issue?
Any plan to have the audio output from the command line?
It would be useful to help to tweak the parameters with some audio feedback
thanks
analyzing sounds from some old TMS5220 from the Talkie library shows lots of repeats.
I like them because my instruments use them a looping point.
I noticed that the repeat flag is never generated when I process sound with BlueWizardor python_wizard
Is it on purpose or it's just not yet implemented?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.