Issue simply getting azure_tts-i2s example working #1297
-
Hello, I have been struggling to get the azure tts example working. I tried the example as it was (with api key, etc filled in), but that didn't work. I tried to narrow down the issue by just using a CSV output instead of the I2S output, but still it "fails to write". Here's my code and debug output. Any help would be really appreciated! I've also tried a simple SineWaveGenerator with I2S and it works perfectly/produces output. I'm using a esp32-eye dev board and an adafruit max98.... breakout. Already have #include <Arduino.h>
#include "AudioTools.h"
//AudioInfo info(44100, 2, 16);
String speechKey = "..."; // deploy a Speech Service in Azure and get both the key and the region. info here: https://azure.microsoft.com/en-us/products/cognitive-services/text-to-speech/
String spechregion = "eastus";
String voice = "en-US-JennyNeural"; // for the next 3 settings, chose from: https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/language-support?tabs=stt#prebuilt-neural-voices
String gender = "Female";
String language = "en-US";
String url_str = "https://" + spechregion + ".tts.speech.microsoft.com/cognitiveservices/v1";
String msg = "This is a demonstration of Phil Schatzmann's AudioTools integrating with the Azure Speech Service. Hope you like it.";
const char* ssid = "iPhone (65)";
const char* password = "testpass";
WiFiClientSecure client_spk;
//URLStream AzureURLStream("iPhone (65)", "testpass");
URLStream AzureURLStream(client_spk);
//I2SStream i2s; // or I2SStream
CsvOutput<int32_t> csvStream(Serial);
WAVDecoder decoder;
EncodedAudioStream out(&csvStream, &decoder); // Decoder stream
StreamCopy copier(out, AzureURLStream); // copy in to out
void setup(){
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Debug);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1500);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
client_spk.setInsecure();
String ssml = "<speak version='1.0' xml:lang='" + language + "'><voice xml:lang='" + language + "' xml:gender='" + gender + "' name='" + voice + "'>" + msg + "</voice></speak>";
AzureURLStream.addRequestHeader("Ocp-Apim-Subscription-Key", speechKey.c_str());
AzureURLStream.addRequestHeader("X-Microsoft-OutputFormat", "riff-16khz-16bit-mono-pcm"); // if you change this, change the settings for i2s and the decoder
AzureURLStream.addRequestHeader(USER_AGENT, String("Arduino with Audiotools version:" + String(AUDIOTOOLS_VERSION)).c_str());
AzureURLStream.begin(url_str.c_str(), "audio/wav", POST, "application/ssml+xml", ssml.c_str());
csvStream.begin();
}
void loop(){
copier.copy();
}
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
out is missing a begin() call, so it is not open... |
Beta Was this translation helpful? Give feedback.
-
What would be the related debug log ? I don't recall having seen any chunked result. Maybe there is an issue related to that. I propose that you try to change the protocol to HTTP/1.0 What is the reason for your strange and complicated https logic ? |
Beta Was this translation helpful? Give feedback.
-
Ok, if I manually set (Edit: Last question-when it starts playing audio there's about a half second of static where the audio is unintelligible, then the rest is fine. Is there a way for me to fix this? |
Beta Was this translation helpful? Give feedback.
out is missing a begin() call, so it is not open...