Skip to content

Commit 395a23b

Browse files
author
Jim Bennett
authored
Adding who terminal translate (#264)
* Update README.md * Spelling fixes * Update hardware.md * Adding IoT for beginners episode * Adding intro video * Fixing formatting of read more and self study sections. * Adding instructions for installing the ReSpeaker * Adding auth to language understanding * Adding Wio terminal timer setting * Update config.h * Fixing links and images * Increasing version numbers for SD card fix * Adding SD card requirement * speech and translations * Adding more on translations * All Wio Terminal now working except playing audio
1 parent 9cd654d commit 395a23b

File tree

97 files changed

+4569
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+4569
-124
lines changed

1-getting-started/lessons/4-connect-internet/code-commands/wio-terminal/nightlight/platformio.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ lib_deps =
1616
knolleary/PubSubClient @ 2.8
1717
bblanchon/ArduinoJson @ 6.17.3
1818
seeed-studio/Seeed Arduino rpcWiFi @ 1.0.5
19-
seeed-studio/Seeed Arduino FS @ 2.0.3
20-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
19+
seeed-studio/Seeed Arduino FS @ 2.1.1
20+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
2121
seeed-studio/Seeed Arduino rpcUnified @ 2.1.3
2222
seeed-studio/Seeed_Arduino_mbedtls @ 3.0.1

1-getting-started/lessons/4-connect-internet/code-commands/wio-terminal/nightlight/src/main.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ void loop()
100100
doc["light"] = light;
101101

102102
string telemetry;
103-
JsonObject obj = doc.as<JsonObject>();
104-
serializeJson(obj, telemetry);
103+
serializeJson(doc, telemetry);
105104

106105
Serial.print("Sending telemetry ");
107106
Serial.println(telemetry.c_str());

1-getting-started/lessons/4-connect-internet/code-mqtt/wio-terminal/nightlight/platformio.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ framework = arduino
1515
lib_deps =
1616
knolleary/PubSubClient @ 2.8
1717
seeed-studio/Seeed Arduino rpcWiFi @ 1.0.5
18-
seeed-studio/Seeed Arduino FS @ 2.0.3
19-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
18+
seeed-studio/Seeed Arduino FS @ 2.1.1
19+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
2020
seeed-studio/Seeed Arduino rpcUnified @ 2.1.3
2121
seeed-studio/Seeed_Arduino_mbedtls @ 3.0.1

1-getting-started/lessons/4-connect-internet/code-telemetry/wio-terminal/nightlight/platformio.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ framework = arduino
1515
lib_deps =
1616
knolleary/PubSubClient @ 2.8
1717
seeed-studio/Seeed Arduino rpcWiFi @ 1.0.5
18-
seeed-studio/Seeed Arduino FS @ 2.0.3
19-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
18+
seeed-studio/Seeed Arduino FS @ 2.1.1
19+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
2020
seeed-studio/Seeed Arduino rpcUnified @ 2.1.3
2121
seeed-studio/Seeed_Arduino_mbedtls @ 3.0.1
2222
bblanchon/ArduinoJson @ 6.17.3

1-getting-started/lessons/4-connect-internet/code-telemetry/wio-terminal/nightlight/src/main.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ void loop()
7474
doc["light"] = light;
7575

7676
string telemetry;
77-
JsonObject obj = doc.as<JsonObject>();
78-
serializeJson(obj, telemetry);
77+
serializeJson(doc, telemetry);
7978

8079
Serial.print("Sending telemetry ");
8180
Serial.println(telemetry.c_str());

1-getting-started/lessons/4-connect-internet/wio-terminal-mqtt.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Install the Arduino libraries.
2525
```ini
2626
lib_deps =
2727
seeed-studio/Seeed Arduino rpcWiFi @ 1.0.5
28-
seeed-studio/Seeed Arduino FS @ 2.0.3
29-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
28+
seeed-studio/Seeed Arduino FS @ 2.1.1
29+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
3030
seeed-studio/Seeed Arduino rpcUnified @ 2.1.3
3131
seeed-studio/Seeed_Arduino_mbedtls @ 3.0.1
3232
```

1-getting-started/lessons/4-connect-internet/wio-terminal-telemetry.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ Publish telemetry to the MQTT broker.
5353
doc["light"] = light;
5454

5555
string telemetry;
56-
JsonObject obj = doc.as<JsonObject>();
57-
serializeJson(obj, telemetry);
56+
serializeJson(doc, telemetry);
5857

5958
Serial.print("Sending telemetry ");
6059
Serial.println(telemetry.c_str());

2-farm/lessons/1-predict-plant-growth/code-publish-temperature/wio-terminal/temperature-sensor/platformio.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ lib_deps =
1717
knolleary/PubSubClient @ 2.8
1818
bblanchon/ArduinoJson @ 6.17.3
1919
seeed-studio/Seeed Arduino rpcWiFi @ 1.0.5
20-
seeed-studio/Seeed Arduino FS @ 2.0.3
21-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
20+
seeed-studio/Seeed Arduino FS @ 2.1.1
21+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
2222
seeed-studio/Seeed Arduino rpcUnified @ 2.1.3
2323
seeed-studio/Seeed_Arduino_mbedtls @ 3.0.1

2-farm/lessons/1-predict-plant-growth/code-publish-temperature/wio-terminal/temperature-sensor/src/main.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ void loop()
7777
doc["temperature"] = temp_hum_val[1];
7878

7979
string telemetry;
80-
JsonObject obj = doc.as<JsonObject>();
81-
serializeJson(obj, telemetry);
80+
serializeJson(doc, telemetry);
8281

8382
Serial.print("Sending telemetry ");
8483
Serial.println(telemetry.c_str());

2-farm/lessons/3-automated-plant-watering/code-mqtt/wio-terminal/soil-moisture-sensor/platformio.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ lib_deps =
1616
knolleary/PubSubClient @ 2.8
1717
bblanchon/ArduinoJson @ 6.17.3
1818
seeed-studio/Seeed Arduino rpcWiFi @ 1.0.5
19-
seeed-studio/Seeed Arduino FS @ 2.0.3
20-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
19+
seeed-studio/Seeed Arduino FS @ 2.1.1
20+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
2121
seeed-studio/Seeed Arduino rpcUnified @ 2.1.3
2222
seeed-studio/Seeed_Arduino_mbedtls @ 3.0.1

2-farm/lessons/3-automated-plant-watering/code-mqtt/wio-terminal/soil-moisture-sensor/src/main.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ void loop()
100100
doc["soil_moisture"] = soil_moisture;
101101

102102
string telemetry;
103-
JsonObject obj = doc.as<JsonObject>();
104-
serializeJson(obj, telemetry);
103+
serializeJson(doc, telemetry);
105104

106105
Serial.print("Sending telemetry ");
107106
Serial.println(telemetry.c_str());

2-farm/lessons/4-migrate-your-plant-to-the-cloud/code/wio-terminal/soil-moisture-sensor/platformio.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ framework = arduino
1515
lib_deps =
1616
bblanchon/ArduinoJson @ 6.17.3
1717
seeed-studio/Seeed Arduino rpcWiFi @ 1.0.5
18-
seeed-studio/Seeed Arduino FS @ 2.0.3
19-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
18+
seeed-studio/Seeed Arduino FS @ 2.1.1
19+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
2020
seeed-studio/Seeed Arduino rpcUnified @ 2.1.3
2121
seeed-studio/Seeed_Arduino_mbedtls @ 3.0.1
2222
seeed-studio/Seeed Arduino RTC @ 2.0.0

2-farm/lessons/4-migrate-your-plant-to-the-cloud/code/wio-terminal/soil-moisture-sensor/src/main.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ void loop()
120120
doc["soil_moisture"] = soil_moisture;
121121

122122
string telemetry;
123-
JsonObject obj = doc.as<JsonObject>();
124-
serializeJson(obj, telemetry);
123+
serializeJson(doc, telemetry);
125124

126125
Serial.print("Sending telemetry ");
127126
Serial.println(telemetry.c_str());

3-transport/lessons/2-store-location-data/code/wio-terminal/gps-sensor/platformio.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ framework = arduino
1515
lib_deps =
1616
bblanchon/ArduinoJson @ 6.17.3
1717
seeed-studio/Seeed Arduino rpcWiFi @ 1.0.5
18-
seeed-studio/Seeed Arduino FS @ 2.0.3
19-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
18+
seeed-studio/Seeed Arduino FS @ 2.1.1
19+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
2020
seeed-studio/Seeed Arduino rpcUnified @ 2.1.3
2121
seeed-studio/Seeed_Arduino_mbedtls @ 3.0.1
2222
seeed-studio/Seeed Arduino RTC @ 2.0.0

4-manufacturing/lessons/2-check-fruit-from-device/code-camera/wio-terminal/fruit-quality-detector/platformio.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ board = seeed_wio_terminal
1414
framework = arduino
1515
lib_deps =
1616
seeed-studio/Seeed Arduino rpcWiFi @ 1.0.5
17-
seeed-studio/Seeed Arduino FS @ 2.0.3
18-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
17+
seeed-studio/Seeed Arduino FS @ 2.1.1
18+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
1919
seeed-studio/Seeed Arduino rpcUnified @ 2.1.3
2020
seeed-studio/Seeed_Arduino_mbedtls @ 3.0.1
2121
seeed-studio/Seeed Arduino RTC @ 2.0.0

4-manufacturing/lessons/2-check-fruit-from-device/code-classify/wio-terminal/fruit-quality-detector/platformio.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ board = seeed_wio_terminal
1414
framework = arduino
1515
lib_deps =
1616
seeed-studio/Seeed Arduino rpcWiFi @ 1.0.5
17-
seeed-studio/Seeed Arduino FS @ 2.0.3
18-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
17+
seeed-studio/Seeed Arduino FS @ 2.1.1
18+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
1919
seeed-studio/Seeed Arduino rpcUnified @ 2.1.3
2020
seeed-studio/Seeed_Arduino_mbedtls @ 3.0.1
2121
seeed-studio/Seeed Arduino RTC @ 2.0.0

4-manufacturing/lessons/3-run-fruit-detector-edge/code-classify/wio-terminal/fruit-quality-detector/platformio.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ board = seeed_wio_terminal
1414
framework = arduino
1515
lib_deps =
1616
seeed-studio/Seeed Arduino rpcWiFi @ 1.0.5
17-
seeed-studio/Seeed Arduino FS @ 2.0.3
18-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
17+
seeed-studio/Seeed Arduino FS @ 2.1.1
18+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
1919
seeed-studio/Seeed Arduino rpcUnified @ 2.1.3
2020
seeed-studio/Seeed_Arduino_mbedtls @ 3.0.1
2121
seeed-studio/Seeed Arduino RTC @ 2.0.0

5-retail/lessons/2-check-stock-device/code-count/wio-terminal/stock-counter/platformio.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ board = seeed_wio_terminal
1414
framework = arduino
1515
lib_deps =
1616
seeed-studio/Seeed Arduino rpcWiFi @ 1.0.5
17-
seeed-studio/Seeed Arduino FS @ 2.0.3
18-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
17+
seeed-studio/Seeed Arduino FS @ 2.1.1
18+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
1919
seeed-studio/Seeed Arduino rpcUnified @ 2.1.3
2020
seeed-studio/Seeed_Arduino_mbedtls @ 3.0.1
2121
seeed-studio/Seeed Arduino RTC @ 2.0.0

5-retail/lessons/2-check-stock-device/code-detect/wio-terminal/stock-counter/platformio.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ board = seeed_wio_terminal
1414
framework = arduino
1515
lib_deps =
1616
seeed-studio/Seeed Arduino rpcWiFi @ 1.0.5
17-
seeed-studio/Seeed Arduino FS @ 2.0.3
18-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
17+
seeed-studio/Seeed Arduino FS @ 2.1.1
18+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
1919
seeed-studio/Seeed Arduino rpcUnified @ 2.1.3
2020
seeed-studio/Seeed_Arduino_mbedtls @ 3.0.1
2121
seeed-studio/Seeed Arduino RTC @ 2.0.0

6-consumer/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The latest iterations are now part of our smart devices. In kitchens in homes al
66

77
In these 4 lessons you'll learn how to build a smart timer, using AI to recognize your voice, understand what you are asking for, and reply with information about your timer. You'll also add support for multiple languages.
88

9+
> ⚠️ Working with speech and microphone data uses a lot of memory, meaning it is easy to hit limits on microcontrollers. The project here works around these issues, but be aware the Wio Terminal labs are complex and may take more time that other labs in this curriculum.
10+
911
> 💁 These lessons will use some cloud resources. If you don't complete all the lessons in this project, make sure you [clean up your project](../clean-up.md).
1012
1113
## Topics

6-consumer/lessons/1-speech-recognition/code-record/wio-terminal/smart-timer/platformio.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ platform = atmelsam
1313
board = seeed_wio_terminal
1414
framework = arduino
1515
lib_deps =
16-
seeed-studio/Seeed Arduino FS @ 2.0.3
17-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
16+
seeed-studio/Seeed Arduino FS @ 2.1.1
17+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
1818
build_flags =
1919
-DSFUD_USING_QSPI

6-consumer/lessons/1-speech-recognition/code-speech-to-text/wio-terminal/smart-timer/platformio.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ platform = atmelsam
1313
board = seeed_wio_terminal
1414
framework = arduino
1515
lib_deps =
16-
seeed-studio/Seeed Arduino FS @ 2.0.3
17-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
16+
seeed-studio/Seeed Arduino FS @ 2.1.1
17+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
1818
seeed-studio/Seeed Arduino rpcWiFi @ 1.0.5
1919
seeed-studio/Seeed Arduino rpcUnified @ 2.1.3
2020
seeed-studio/Seeed_Arduino_mbedtls @ 3.0.1

6-consumer/lessons/1-speech-recognition/code-speech-to-text/wio-terminal/smart-timer/src/speech_to_text.h

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ class SpeechToText
6767
return text;
6868
}
6969

70+
String AccessToken()
71+
{
72+
return _access_token;
73+
}
74+
7075
private:
7176
String getAccessToken()
7277
{

6-consumer/lessons/1-speech-recognition/wio-terminal-audio.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ Once each buffer has been captured, it can be written to the flash memory. Flash
2424

2525
```ini
2626
lib_deps =
27-
seeed-studio/Seeed Arduino FS @ 2.0.3
28-
seeed-studio/Seeed Arduino SFUD @ 2.0.1
27+
seeed-studio/Seeed Arduino FS @ 2.1.1
28+
seeed-studio/Seeed Arduino SFUD @ 2.0.2
2929
```
3030

3131
1. Open the `main.cpp` file and add the following include directive for the flash memory library to the top of the file:

6-consumer/lessons/1-speech-recognition/wio-terminal-microphone.md

+14
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ To connect the ReSpeaker 2-Mics Pi Hat you will need 40 pin-to-pin (also referre
1818

1919
> 💁 If you are comfortable soldering, then you can use the [40 Pin Raspberry Pi Hat Adapter Board For Wio Terminal](https://www.seeedstudio.com/40-Pin-Raspberry-Pi-Hat-Adapter-Board-For-Wio-Terminal-p-4730.html) to connect the ReSpeaker.
2020
21+
You will also need an SD card to use to download and playback audio. The Wio Terminal only supports SD Cards up to 16GB in size, and these need to be formatted as FAT32 or exFAT.
22+
2123
### Task - connect the ReSpeaker Pi Hat
2224

2325
1. With the Wio Terminal powered off, connect the ReSpeaker 2-Mics Pi Hat to the Wio Terminal using the jumper leads and the GPIO sockets on the back of the Wio Terminal:
@@ -59,3 +61,15 @@ To connect the ReSpeaker 2-Mics Pi Hat you will need 40 pin-to-pin (also referre
5961
* If you are using a speaker with a 3.5mm jack, or headphones, insert them into the 3.5mm jack socket.
6062

6163
![A speaker connected to the ReSpeaker via the 3.5mm jack socket](../../../images/respeaker-35mm-speaker.png)
64+
65+
### Task - set up the SD card
66+
67+
1. Connect the SD Card to your computer, using na external reader if you don't have an SD Card slot.
68+
69+
1. Format the SD Card using the appropriate tool on your computer, making sure to use a FAT32 or exFAT file system
70+
71+
1. Insert the SD card into the SD Card slot on the left-hand side of the Wio Terminal, just below the power button. Make sure the card is all the way in and clicks in - you may need a thin tool or another SD Card to help push it all the way in.
72+
73+
![Inserting the SD card into the SD card slot below the power switch](../../../images/wio-sd-card.png)
74+
75+
> 💁 To eject the SD Card, you need to push it in slightly and it will eject. You will need a thin tool to do this such as a flat-head screwdriver or another SD Card.

6-consumer/lessons/1-speech-recognition/wio-terminal-speech-to-text.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,15 @@ The audio can be sent to the speech service using the REST API. To use the speec
180180

181181
This code builds the URL for the token issuer API using the location of the speech resource. It then creates an `HTTPClient` to make the web request, setting it up to use the WiFi client configured with the token endpoints certificate. It sets the API key as a header for the call. It then makes a POST request to get the certificate, retrying if it gets any errors. Finally the access token is returned.
182182

183+
1. To the `public` section, add a method to get the access token. This will be needed in later lessons to convert text to speech.
184+
185+
```cpp
186+
String AccessToken()
187+
{
188+
return _access_token;
189+
}
190+
```
191+
183192
1. To the `public` section, add an `init` method that sets up the token client:
184193

185194
```cpp
@@ -497,7 +506,7 @@ The audio can be sent to the speech service using the REST API. To use the speec
497506
Serial.println(text);
498507
```
499508
500-
1. Build this code, upload it to your Wio Terminal and test it out through the serial monitor. Press the C button (the one on the left-hand side, closest to the power switch), and speak. 4 seconds of audio will be captured, then converted to text.
509+
1. Build this code, upload it to your Wio Terminal and test it out through the serial monitor. Once you see `Ready` in the serial monitor, press the C button (the one on the left-hand side, closest to the power switch), and speak. 4 seconds of audio will be captured, then converted to text.
501510
502511
```output
503512
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time

6-consumer/lessons/2-language-understanding/README.md

+34-6
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ Rather than calling LUIS from the IoT device, you can use serverless code with a
274274
func new --name text-to-timer --template "HTTP trigger"
275275
```
276276
277-
This will crate an HTTP trigger called `text-to-timer`.
277+
This will create an HTTP trigger called `text-to-timer`.
278278
279279
1. Test the HTTP trigger by running the functions app. When it runs you will see the endpoint listed in the output:
280280
@@ -493,9 +493,35 @@ Rather than calling LUIS from the IoT device, you can use serverless code with a
493493
494494
### Task - make your function available to your IoT device
495495
496-
1. For your IoT device to call your REST endpoint, it will need to know the URL. When you accessed it earlier, you used `localhost`, which is a shortcut to access REST endpoints on your local machine. To allow you IoT device to get access, you need to either:
496+
1. For your IoT device to call your REST endpoint, it will need to know the URL. When you accessed it earlier, you used `localhost`, which is a shortcut to access REST endpoints on your local machine. To allow you IoT device to get access, you need to either publish to the cloud, or get your IP address to access it locally.
497+
498+
> ⚠️ If you are using a Wio Terminal, it is easier to run the function app locally, as there will be a dependency on libraries that mean you cannot deploy the function app in the same way as you have done before. Run the function app locally and access it via your computers IP address. If you do want to deploy to the cloud, information will be provided in a later lesson on the way to do this.
499+
500+
* Publish the Functions app - follow the instructions in earlier lessons to publish your functions app to the cloud. Once published, the URL will be `https://<APP_NAME>.azurewebsites.net/api/text-to-timer`, where `<APP_NAME>` will be the name of your functions app. Make sure to also publish your local settings.
501+
502+
When working with HTTP triggers, they are secured by default with a function app key. To get this key, run the following command:
503+
504+
```sh
505+
az functionapp keys list --resource-group smart-timer \
506+
--name <APP_NAME>
507+
```
508+
509+
Copy the value of the `default` entry from the `functionKeys` section.
510+
511+
```output
512+
{
513+
"functionKeys": {
514+
"default": "sQO1LQaeK9N1qYD6SXeb/TctCmwQEkToLJU6Dw8TthNeUH8VA45hlA=="
515+
},
516+
"masterKey": "RSKOAIlyvvQEQt9dfpabJT018scaLpQu9p1poHIMCxx5LYrIQZyQ/g==",
517+
"systemKeys": {}
518+
}
519+
```
520+
521+
This key will need to be added as a query parameter to the URL, so the final URL will be `https://<APP_NAME>.azurewebsites.net/api/text-to-timer?code=<FUNCTION_KEY>`, where `<APP_NAME>` will be the name of your functions app, and `<FUNCTION_KEY>` will be your default function key.
522+
523+
> 💁 You can change the type of authorization of the HTTP trigger using `authlevel` setting in the `function.json` file. You can read more about this in the [configuration section of the Azure Functions HTTP trigger documentation on Microsoft docs](https://docs.microsoft.com/azure/azure-functions/functions-bindings-http-webhook-trigger?tabs=python&WT.mc_id=academic-17441-jabenn#configuration).
497524
498-
* Publish the Functions app - follow the instructions in earlier lessons to publish your functions app to the cloud. Once published, the URL will be `http://<APP_NAME>.azurewebsites.net/api/text-to-timer`, where `<APP_NAME>` will be the name of your functions app.
499525
* Run the functions app locally, and access using the IP address - you can get the IP address of your computer on your local network, and use that to build the URL.
500526
501527
Find your IP address:
@@ -504,11 +530,13 @@ Rather than calling LUIS from the IoT device, you can use serverless code with a
504530
* On macOS, follow the [how to find you IP address on a Mac guide](https://www.hellotech.com/guide/for/how-to-find-ip-address-on-mac)
505531
* On linux, follow the section on finding your private IP address in the [how to find your IP address in Linux guide](https://opensource.com/article/18/5/how-find-ip-address-linux)
506532
507-
Once you have your IP address, you will able to access the function at `http://<IP_ADDRESS>:7071/api/text-to-timer`, where `<IP_ADDRESS>` will be your IP address, for example `http://192.168.1.10:7071/api/text-to-timer`.
533+
Once you have your IP address, you will able to access the function at `http://<IP_ADDRESS>:7071/api/text-to-timer`, where `<IP_ADDRESS>` will be your IP address, for example `http://192.168.1.10:7071/api/text-to-timer`.
534+
535+
> 💁 Not that this uses port 7071, so after the IP address you will need to have `:7071`.
508536
509-
> 💁 This will only work if your IoT device is on the same network as your computer.
537+
> 💁 This will only work if your IoT device is on the same network as your computer.
510538
511-
1. Test the endpoint by accessing it using your browser.
539+
1. Test the endpoint by accessing it using curl.
512540
513541
---
514542
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import json
2+
import os
3+
import requests
4+
5+
import azure.functions as func
6+
7+
def main(req: func.HttpRequest) -> func.HttpResponse:
8+
location = os.environ['SPEECH_LOCATION']
9+
speech_key = os.environ['SPEECH_KEY']
10+
11+
req_body = req.get_json()
12+
language = req_body['language']
13+
14+
url = f'https://{location}.tts.speech.microsoft.com/cognitiveservices/voices/list'
15+
16+
headers = {
17+
'Ocp-Apim-Subscription-Key': speech_key
18+
}
19+
20+
response = requests.get(url, headers=headers)
21+
voices_json = json.loads(response.text)
22+
23+
voices = filter(lambda x: x['Locale'].lower() == language.lower(), voices_json)
24+
voices = map(lambda x: x['ShortName'], voices)
25+
26+
return func.HttpResponse(json.dumps(list(voices)), status_code=200)

0 commit comments

Comments
 (0)