I am trying to to make a simple voice assistant using python. However, after months of hard work, I realized that the TTS I was using (pyttsx3) will not load onto the Raspberry Pi Pico W. Is there any way to get TTS on the Pico?
I have tried using the Hugging face inference API for my code, so I used this snippet:
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",
})
(Note that in my real code I put my actual API token and Wi-Fi password)
However, every time I run the code (with actual API token) it gives me the same error:
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
what should I do?