更新MPY的固件,soar和nova也更新至v1.25.0
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,35 +1,27 @@
|
||||
"""
|
||||
mixgo_zero Zi Voice Onboard resources
|
||||
mixgo_nova Voice Onboard resources
|
||||
|
||||
Micropython library for the mixgo_zero Zi Onboard resources
|
||||
Micropython library for the mixgo_nova Onboard resources
|
||||
=======================================================
|
||||
|
||||
#Preliminary composition 20230818
|
||||
|
||||
dahanzimin From the Mixly Team
|
||||
@dahanzimin From the Mixly Team
|
||||
"""
|
||||
import ustruct
|
||||
import time
|
||||
import music_spk
|
||||
import es8374
|
||||
|
||||
from machine import Pin, I2S
|
||||
import ustruct
|
||||
import music_spk
|
||||
from machine import Pin
|
||||
from esp_i2s import I2S
|
||||
from esp_tts import TTS
|
||||
from mixgo_nova import onboard_i2c
|
||||
|
||||
sample_rate = 22050
|
||||
ob_code = es8374.ES8374(onboard_i2c)
|
||||
time.sleep(0.2)
|
||||
|
||||
# ps 特殊改双全工i2s支持
|
||||
ob_audio = I2S(0, sck=Pin(34), ws=Pin(47), dout=Pin(48), din=Pin(33), mck=Pin(35), mode=I2S.RTX, bits=16, format=I2S.MONO, rate=sample_rate, ibuf=20000)
|
||||
|
||||
spk_midi = music_spk.MIDI(ob_audio, sample_rate)
|
||||
|
||||
ob_tts = TTS()
|
||||
ob_audio = I2S(0, sck=Pin(34), ws=Pin(47), sd_out=Pin(48), sd_in=Pin(33), mck=Pin(35), channels=1)
|
||||
ob_audio.start()
|
||||
spk_midi = music_spk.MIDI(ob_audio)
|
||||
|
||||
def u2s(n):
|
||||
return n if n < (1 << 15) else n - (1 << 16)
|
||||
|
||||
|
||||
def sound_level():
|
||||
buf = bytearray(100)
|
||||
values = []
|
||||
@@ -38,63 +30,64 @@ def sound_level():
|
||||
values.append(u2s(buf[i * 2] | buf[i * 2 + 1] << 8))
|
||||
return max(values) - min(values)
|
||||
|
||||
def play_tts(text, speed=3):
|
||||
ob_audio.stop()
|
||||
ob_audio.sample_rate = 16000
|
||||
ob_audio.start()
|
||||
if ob_tts.parse_chinese(text):
|
||||
while True:
|
||||
data = ob_tts.stream_play(speed)
|
||||
if not data:
|
||||
break
|
||||
else:
|
||||
ob_audio.write(data)
|
||||
|
||||
def play_audio(path):
|
||||
def play_audio(path, chunk=1024):
|
||||
file = open(path, 'rb')
|
||||
header = file.read(44)
|
||||
if header[8:12] != b'WAVE':
|
||||
raise Error('not a WAVE file')
|
||||
_rate = ustruct.unpack('<I', header[24:28])[0]
|
||||
print("sample_rate", _rate)
|
||||
ob_audio.stop()
|
||||
ob_audio.sample_rate = ustruct.unpack('<I', header[24:28])[0]
|
||||
ob_audio.start()
|
||||
file.seek(44)
|
||||
ob_audio = I2S(0, sck=Pin(34), ws=Pin(47), dout=Pin(48), din=Pin(33), mck=Pin(
|
||||
35), mode=I2S.RTX, bits=16, format=I2S.MONO, rate=_rate, ibuf=20000)
|
||||
while True:
|
||||
block = file.read(1024)
|
||||
block = file.read(chunk)
|
||||
if not block:
|
||||
break
|
||||
ob_audio.write(block)
|
||||
ob_audio = I2S(0, sck=Pin(34), ws=Pin(47), dout=Pin(48), din=Pin(33), mck=Pin(
|
||||
35), mode=I2S.RTX, bits=16, format=I2S.MONO, rate=sample_rate, ibuf=20000)
|
||||
file.close()
|
||||
|
||||
|
||||
def record_audio(path, seconds=5):
|
||||
ob_audio = I2S(0, sck=Pin(34), ws=Pin(47), dout=Pin(48), din=Pin(33), mck=Pin(
|
||||
35), mode=I2S.RTX, bits=16, format=I2S.MONO, rate=sample_rate*4, ibuf=20000)
|
||||
def record_audio(path, seconds=5, sample_rate=22050, chunk=512):
|
||||
ob_audio.stop()
|
||||
ob_audio.sample_rate = sample_rate
|
||||
ob_audio.start()
|
||||
file_size = sample_rate * 16 * 1 * seconds // 8
|
||||
wav_header = bytearray(44)
|
||||
wav_header[0:4] = b'RIFF'
|
||||
ustruct.pack_into('<I', wav_header, 4, file_size + 36)
|
||||
wav_header[8:40] = b'WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00"V\x00\x00D\xac\x00\x00\x02\x00\x10\x00data'
|
||||
ustruct.pack_into('<I', wav_header, 40, file_size)
|
||||
|
||||
buf = bytearray(512)
|
||||
buf = bytearray(chunk)
|
||||
file = open(path, 'wb')
|
||||
file.write(wav_header)
|
||||
for _ in range(file_size // 512):
|
||||
for _ in range(file_size // chunk):
|
||||
ob_audio.readinto(buf)
|
||||
file.write(buf)
|
||||
ob_audio = I2S(0, sck=Pin(34), ws=Pin(47), dout=Pin(48), din=Pin(33), mck=Pin(
|
||||
35), mode=I2S.RTX, bits=16, format=I2S.MONO, rate=sample_rate, ibuf=20000)
|
||||
file.close()
|
||||
file.write(buf)
|
||||
file.close()
|
||||
|
||||
|
||||
def play_audio_url(url):
|
||||
def play_audio_url(url, chunk=1024):
|
||||
import urequests
|
||||
response = urequests.get(url, stream=True)
|
||||
header = response.raw.read(44)
|
||||
if header[8:12] != b'WAVE':
|
||||
raise Error('not a WAVE file')
|
||||
_rate = ustruct.unpack('<I', header[24:28])[0]
|
||||
# print("sample_rate", _rate)
|
||||
ob_audio = I2S(0, sck=Pin(34), ws=Pin(47), dout=Pin(48), din=Pin(33), mck=Pin(
|
||||
35), mode=I2S.RTX, bits=16, format=I2S.MONO, rate=_rate, ibuf=20000)
|
||||
ob_audio.stop()
|
||||
ob_audio.sample_rate = ustruct.unpack('<I', header[24:28])[0]
|
||||
ob_audio.start()
|
||||
while True:
|
||||
block = response.raw.read(1024)
|
||||
block = response.raw.read(chunk)
|
||||
if not block:
|
||||
break
|
||||
ob_audio.write(block)
|
||||
ob_audio = I2S(0, sck=Pin(34), ws=Pin(47), dout=Pin(48), din=Pin(33), mck=Pin(
|
||||
35), mode=I2S.RTX, bits=16, format=I2S.MONO, rate=sample_rate, ibuf=20000)
|
||||
response.close()
|
||||
|
||||
@@ -1,32 +1,27 @@
|
||||
"""
|
||||
Soar Voice Onboard resources
|
||||
mixgo_soar Voice Onboard resources
|
||||
|
||||
Micropython library for the Soar Onboard resources
|
||||
Micropython library for the mixgo_soar Onboard resources
|
||||
=======================================================
|
||||
@dahanzimin From the Mixly Team
|
||||
"""
|
||||
import ustruct
|
||||
import time
|
||||
import music_spk
|
||||
import es8374
|
||||
|
||||
from machine import Pin, I2S
|
||||
import ustruct
|
||||
import music_spk
|
||||
from machine import Pin
|
||||
from esp_i2s import I2S
|
||||
from esp_tts import TTS
|
||||
from mixgo_soar import onboard_i2c
|
||||
|
||||
sample_rate = 22050
|
||||
ob_code = es8374.ES8374(onboard_i2c)
|
||||
time.sleep(0.2)
|
||||
|
||||
# ps 特殊改双全工i2s支持
|
||||
ob_audio = I2S(0, sck=Pin(37), din=Pin(36), ws=Pin(35), dout=Pin(34), mck=Pin(33), mode=I2S.RTX, bits=16, format=I2S.MONO, rate=sample_rate, ibuf=20000)
|
||||
|
||||
spk_midi = music_spk.MIDI(ob_audio, sample_rate)
|
||||
|
||||
ob_tts = TTS()
|
||||
ob_audio = I2S(0, sck=Pin(37), ws=Pin(35), sd_out=Pin(34), sd_in=Pin(36), mck=Pin(33), channels=1)
|
||||
ob_audio.start()
|
||||
spk_midi = music_spk.MIDI(ob_audio)
|
||||
|
||||
def u2s(n):
|
||||
return n if n < (1 << 15) else n - (1 << 16)
|
||||
|
||||
|
||||
def sound_level():
|
||||
buf = bytearray(100)
|
||||
values = []
|
||||
@@ -35,63 +30,64 @@ def sound_level():
|
||||
values.append(u2s(buf[i * 2] | buf[i * 2 + 1] << 8))
|
||||
return max(values) - min(values)
|
||||
|
||||
def play_tts(text, speed=3):
|
||||
ob_audio.stop()
|
||||
ob_audio.sample_rate = 16000
|
||||
ob_audio.start()
|
||||
if ob_tts.parse_chinese(text):
|
||||
while True:
|
||||
data = ob_tts.stream_play(speed)
|
||||
if not data:
|
||||
break
|
||||
else:
|
||||
ob_audio.write(data)
|
||||
|
||||
def play_audio(path):
|
||||
def play_audio(path, chunk=1024):
|
||||
file = open(path, 'rb')
|
||||
header = file.read(44)
|
||||
if header[8:12] != b'WAVE':
|
||||
raise Error('not a WAVE file')
|
||||
_rate = ustruct.unpack('<I', header[24:28])[0]
|
||||
print("sample_rate", _rate)
|
||||
ob_audio.stop()
|
||||
ob_audio.sample_rate = ustruct.unpack('<I', header[24:28])[0]
|
||||
ob_audio.start()
|
||||
file.seek(44)
|
||||
ob_audio = I2S(0, sck=Pin(37), din=Pin(36), ws=Pin(35), dout=Pin(34), mck=Pin(
|
||||
33), mode=I2S.RTX, bits=16, format=I2S.MONO, rate=_rate, ibuf=20000)
|
||||
while True:
|
||||
block = file.read(1024)
|
||||
block = file.read(chunk)
|
||||
if not block:
|
||||
break
|
||||
ob_audio.write(block)
|
||||
ob_audio = I2S(0, sck=Pin(37), din=Pin(36), ws=Pin(35), dout=Pin(34), mck=Pin(
|
||||
33), mode=I2S.RTX, bits=16, format=I2S.MONO, rate=sample_rate, ibuf=20000)
|
||||
file.close()
|
||||
|
||||
|
||||
def record_audio(path, seconds=5):
|
||||
ob_audio = I2S(0, sck=Pin(37), din=Pin(36), ws=Pin(35), dout=Pin(34), mck=Pin(
|
||||
33), mode=I2S.RTX, bits=16, format=I2S.MONO, rate=sample_rate*4, ibuf=20000)
|
||||
def record_audio(path, seconds=5, sample_rate=22050, chunk=512):
|
||||
ob_audio.stop()
|
||||
ob_audio.sample_rate = sample_rate
|
||||
ob_audio.start()
|
||||
file_size = sample_rate * 16 * 1 * seconds // 8
|
||||
wav_header = bytearray(44)
|
||||
wav_header[0:4] = b'RIFF'
|
||||
ustruct.pack_into('<I', wav_header, 4, file_size + 36)
|
||||
wav_header[8:40] = b'WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00"V\x00\x00D\xac\x00\x00\x02\x00\x10\x00data'
|
||||
ustruct.pack_into('<I', wav_header, 40, file_size)
|
||||
|
||||
buf = bytearray(512)
|
||||
buf = bytearray(chunk)
|
||||
file = open(path, 'wb')
|
||||
file.write(wav_header)
|
||||
for _ in range(file_size // 512):
|
||||
for _ in range(file_size // chunk):
|
||||
ob_audio.readinto(buf)
|
||||
file.write(buf)
|
||||
ob_audio = I2S(0, sck=Pin(37), din=Pin(36), ws=Pin(35), dout=Pin(34), mck=Pin(
|
||||
33), mode=I2S.RTX, bits=16, format=I2S.MONO, rate=sample_rate, ibuf=20000)
|
||||
file.close()
|
||||
file.write(buf)
|
||||
file.close()
|
||||
|
||||
|
||||
def play_audio_url(url):
|
||||
def play_audio_url(url, chunk=1024):
|
||||
import urequests
|
||||
response = urequests.get(url, stream=True)
|
||||
header = response.raw.read(44)
|
||||
if header[8:12] != b'WAVE':
|
||||
raise Error('not a WAVE file')
|
||||
_rate = ustruct.unpack('<I', header[24:28])[0]
|
||||
# print("sample_rate", _rate)
|
||||
ob_audio = I2S(0, sck=Pin(37), din=Pin(36), ws=Pin(35), dout=Pin(34), mck=Pin(
|
||||
33), mode=I2S.RTX, bits=16, format=I2S.MONO, rate=_rate, ibuf=20000)
|
||||
ob_audio.stop()
|
||||
ob_audio.sample_rate = ustruct.unpack('<I', header[24:28])[0]
|
||||
ob_audio.start()
|
||||
while True:
|
||||
block = response.raw.read(1024)
|
||||
block = response.raw.read(chunk)
|
||||
if not block:
|
||||
break
|
||||
ob_audio.write(block)
|
||||
ob_audio = I2S(0, sck=Pin(37), din=Pin(36), ws=Pin(35), dout=Pin(34), mck=Pin(
|
||||
33), mode=I2S.RTX, bits=16, format=I2S.MONO, rate=sample_rate, ibuf=20000)
|
||||
response.close()
|
||||
|
||||
@@ -121,10 +121,10 @@
|
||||
"command": "\"{esptool}\" --chip esp32s3 --port {com} --baud {baudrate} --after hard_reset write_flash -e 0x0 \"{indexPath}/build/Mixgo_Sant_lib_DL-v1.25.0.bin\" 0xF00000 \"{indexPath}/../micropython/build/HZK16_GBK.bin\" 0xC00000 \"{indexPath}/../micropython/build/esp_tts_voice_data_xiaole.dat\""
|
||||
},
|
||||
"micropython:esp32s3:mixgo_nova": {
|
||||
"command": "\"{esptool}\" --chip esp32s3 --port {com} --baud {baudrate} --after hard_reset write_flash -e 0x0 \"{indexPath}/build/Mixgo_Nova_lib-v1.21.0.bin\" 0x700000 \"{indexPath}/../micropython/build/HZK12.bin\""
|
||||
"command": "\"{esptool}\" --chip esp32s3 --port {com} --baud {baudrate} --after hard_reset write_flash -e 0x0 \"{indexPath}/build/Mixgo_Nova_lib-v1.25.0.bin\" 0x700000 \"{indexPath}/../micropython/build/HZK12.bin\" 0x400000 \"{indexPath}/../micropython/build/esp_tts_voice_data_xiaole.dat\""
|
||||
},
|
||||
"micropython:esp32s3:mixgo_soar": {
|
||||
"command": "\"{esptool}\" --chip esp32s3 --port {com} --baud {baudrate} --after hard_reset write_flash -e 0x0 \"{indexPath}/build/Mixgo_Soar_lib-v1.21.0.bin\" 0x700000 \"{indexPath}/../micropython/build/HZK16_GBK.bin\""
|
||||
"command": "\"{esptool}\" --chip esp32s3 --port {com} --baud {baudrate} --after hard_reset write_flash -e 0x0 \"{indexPath}/build/Mixgo_Soar_lib-v1.25.0.bin\" 0x700000 \"{indexPath}/../micropython/build/HZK16_GBK.bin\" 0x400000 \"{indexPath}/../micropython/build/esp_tts_voice_data_xiaole.dat\""
|
||||
},
|
||||
"micropython:esp32s3:generic": {
|
||||
"command": "\"{esptool}\" --chip esp32s3 --port {com} --baud {baudrate} --after=no_reset write_flash -e 0x0 \"{indexPath}/build/Generic_S3_lib-v1.25.0.bin\" 0X3A0000 \"{indexPath}/../micropython/build/HZK12.bin\""
|
||||
@@ -196,10 +196,13 @@
|
||||
"binFile": [
|
||||
{
|
||||
"offset": "0x0000",
|
||||
"path": "./build/Mixgo_Nova_lib-v1.21.0.bin"
|
||||
"path": "./build/Mixgo_Nova_lib-v1.25.0.bin"
|
||||
}, {
|
||||
"offset": "0x700000",
|
||||
"path": "../micropython/build/HZK12.bin"
|
||||
}, {
|
||||
"offset": "0x400000",
|
||||
"path": "../micropython/build/esp_tts_voice_data_xiaole.dat"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -207,10 +210,13 @@
|
||||
"binFile": [
|
||||
{
|
||||
"offset": "0x0000",
|
||||
"path": "./build/Mixgo_Soar_lib-v1.21.0.bin"
|
||||
"path": "./build/Mixgo_Soar_lib-v1.25.0.bin"
|
||||
}, {
|
||||
"offset": "0x700000",
|
||||
"path": "../micropython/build/HZK16_GBK.bin"
|
||||
}, {
|
||||
"offset": "0x400000",
|
||||
"path": "../micropython/build/esp_tts_voice_data_xiaole.dat"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user