Added the scripts used for combining the audio files and flashing
The makebin.sh script takes all the .wav files in a directory, resamples them to 8kHz, 8-bit unsigned integer RAW files. It then concatenates these all together, while creating a text listing of how long each clip is and the start position for that clip. It also spits out some useful C code that does require some modification before being pasted into the code, but makes things much easier for fast prototyping. The programFlash.py script connects to the chip over UART, sends it 64 bytes at a time to program into the flash chip, and repeats this until all the data has been transferred. This mechanism does seem to work, the only part that needs to be tested still is the SPI connection to the flash chip.
This commit is contained in:
parent
28cacf7258
commit
d9b5b15b96
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
|
||||
rm audio.bin
|
||||
rm fsize.txt total.txt
|
||||
|
||||
total=0
|
||||
numfiles=1
|
||||
# Remake all the raw files
|
||||
for f in *.wav ; do
|
||||
name=$(echo $f | cut -f 1 -d '.')
|
||||
sox $f -r 8000 -b 8 -e unsigned-integer -G $name.raw
|
||||
numfiles=$(($numfiles + 1))
|
||||
done
|
||||
|
||||
printf "const uint32_t audioAddress[%d] = { 0x0, " $numfiles > total.txt
|
||||
printf "const uint32_t audioSize[%d] = { " $numfiles > fsize.txt
|
||||
# Concatenate all the raws and list their sizes
|
||||
for f in *.raw ; do
|
||||
cat $f >> audio.bin
|
||||
fsize=$(du -sb $f | awk '{print $1}')
|
||||
total=$(($total + $fsize))
|
||||
printf "%#010x, " $fsize >> fsize.txt
|
||||
printf "%#010x, " $total >> total.txt
|
||||
done
|
||||
|
||||
printf " };" >> fsize.txt
|
||||
printf " };" >> total.txt
|
||||
|
||||
printf "Total filesize is %d\n" $total
|
||||
printf "#define AUDIO_SIZE %d\n" $total
|
||||
echo " "
|
||||
cat fsize.txt
|
||||
echo " "
|
||||
cat total.txt
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import serial
|
||||
import sys
|
||||
def program():
|
||||
print("Starting transfer...\n")
|
||||
with open("audio.bin", "rb") as binFile:
|
||||
sport = serial.Serial(port="/dev/ttyUSB0", baudrate=19200, dsrdtr=True)
|
||||
#sport = serial.Serial(port="/dev/pts/7", baudrate=115200)
|
||||
sport.reset_input_buffer()
|
||||
count = 0
|
||||
while(dataBuffer := binFile.read(64)):
|
||||
sport.read_until(b'\x33')
|
||||
sport.write(dataBuffer)
|
||||
print(".", end="", file=sys.stdout, flush=True)
|
||||
|
||||
sport.close()
|
||||
|
||||
print("All done?")
|
||||
|
||||
if __name__ == '__main__':
|
||||
program()
|
Loading…
Reference in New Issue