如何在Raspberry Pi Pico w上实现文本到语音的转换



我正在尝试使用python制作一个简单的语音助手。然而,经过几个月的努力工作,我意识到我正在使用的TTS (pyttsx3)将无法加载到Raspberry Pi Pico w上。有没有办法在Pico上获得TTS ?

我已经尝试在我的代码中使用拥抱脸推理API,所以我使用了这个代码片段:

import network
import socket
import machine
import urequests as requests
ssid = 'My Wi-Fi network '
password = 'My Wi-Fi password'
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
print("internet connected sucessfully")
API_URL = "https://api-inference.huggingface.co/models/facebook/fastspeech2-en-ljspeech"
headers = {"Authorization": "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()

output = query({
"inputs": "The answer to the universe is 42",
})

(请注意,在我的实际代码中,我放置了实际的API令牌和Wi-Fi密码)

但是,每次我运行代码(使用实际的API令牌),它都会给我相同的错误:
internet connected sucessfully
Traceback (most recent call last):
File "<stdin>", line 20, in <module>
File "<stdin>", line 17, in query
File "urequests.py", line 33, in json
File "urequests.py", line 20, in content
MemoryError: memory allocation failed, allocating 119296 bytes

我该怎么办?

问题是超过SRAM内存的数据量。

请检查树莓派Pico组件并检查什么是微控制器。如果你想要远程使用Raspberry Pi Pico,你总是需要将一个程序放入闪存并创建一个通信协议。

https://datasheets.raspberrypi.com/pico/pico-product-brief.pdf

https://raspberrypi.github.io/pico-sdk-doxygen/modules.html

最新更新