【问题标题】:How to make text to speech on Raspberry Pi Pico W如何在 Raspberry Pi Pico W 上进行文字转语音
【发布时间】:2022-12-15 01:47:00
【问题描述】:

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

我已经尝试在我的代码中使用 Hugging face inference API,所以我使用了这个 sn-p:

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

我应该怎么办?

【问题讨论】:

    标签: out-of-memory artificial-intelligence text-to-speech raspberry-pi-pico


    【解决方案1】:

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

    请查看 Raspberry Pi Pico 组件并查看什么是微控制器。

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

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

    【讨论】:

      猜你喜欢
      • 2022-09-25
      • 2022-08-15
      • 2020-05-24
      • 2023-01-03
      • 2022-08-14
      • 2023-01-03
      • 2023-01-31
      • 1970-01-01
      • 2021-09-28
      相关资源
      最近更新 更多