Prepare
Google Speech-to-Text
Speech-to-Text is an API that is powered by Google's artificial intelligence (AI) technology. You send your audio data to Speech-to-Text, then receive a text transcription of your audio data in response. For more information about how to construct a Speech-to-Text request, see the requests page.
https://cloud.google.com/speech-to-text/docs/before-you-begin?hl=en
Enable Speech-to-Text on a project.
- Make sure billing is enabled for Speech-to-Text.
- Make sure your project has at least one service account.
- Download a service account credential key.
Connect Raspberry Pi
Check out our step-by-step guide:
How to set up your Raspberry Pi 4 for the first time
Connect W5100S-EVB-Pico
W5100S-EVB-Pico is a microcontroller evaluation board based on the Raspberry Pi RP2040 and fully hardwired TCP/IP controller W5100S – and basically works the same as Raspberry Pi Pico board but with additional Ethernet via W5100S.
Setup Google API service
In this tutorial, you'll learn how to use the Speech-to-Text V1 API from a Python application by following these steps:
Select a Google Cloud project and enable the Speech-to-Text API.
- Select a Google Cloud project and enable the Speech-to-Text API.
Set up authentication by creating a service account and downloading a key.
- Set up authentication by creating a service account and downloading a key.
Create a sample application that transcribes an audio file to text.
- Create a sample application that transcribes an audio file to text.
Estimated time to complete: To get started, click Start.
Creating a project on the Google Cloud platform
<step-1> Menu -> IAM & Admin -> Manage resources
<step-2> Go to the page [Manage Resources] and [+CREATE PROJECT] select.
<step-3> Enter a name for the project and press CREATE. This creates a project.
<step-4> Menu -> APIs & servuce -> Library
<step-5> [Cloud Speech-to-Text API] Find and click. [MANAGE] click
Create User Credentials
<step-1> [+CREATE CREDENTIALS] select and Service account click
<step-2> Enter a name for the account and press CREATE
<step-3> Verify that the service account has been created as follows:
Create API key
<step-1> Manage service accounts click. Enter the service account you just created.
<step-2> KEYS -> ADD KEY -> Create new key
<step-3> Press Create while selected as the JSON format.
<step-4> Move the created JSON file to the RPi directory.
<step-5> Now it's time to export the JSON file.
example) pi@raspberry:~ $ export GOOGLE_APPLICATION_CREDENTIALS="KEY_STRING"
Getting Started
Raspberry Pi Setup
- Connect the microphone to the RPi USB port and download the Google.spech library for the Google Speech-to-Text service.
pi@raspberry:~ $ pip install --upgrade google-cloud-speechorpi@raspberry:~ $ python3 -m install --upgrade google-cloud-speech
- Next, download and run mosquitto because you will control the device through mqtt. To install the Mosquitto Broker enter these next commands:
pi@raspberry:~ $ sudo apt install -y mosquitto mosquitto-clients
To make Mosquitto auto start when the Raspberry Pi boots, you need to run the following command (this means that the Mosquitto broker will automatically start when the Raspberry Pi starts :)
pi@raspberry:~ $ sudo systemctl enable mosquitto.service
Now, test the installation by running the following command:
pi@raspberry:~ $ mosquitto -v
- We will issue the data converted from Google STT to Text again in MQTT, so we will add the following command to the code. The Speech-to-Text and MQTT integrated source code is attached below.
mosquitto_pub -d -h mqtt_host -t mqtt_topic -m mqtt_msg
WIZnet W5100S-EVB-Pico setup
- Installing CircuitPython
Install CircuitPython
on...