Hi all.
The compiling error: "Teensyduino version 1.20 or later is required to compile the Audio library happened, even after installed teensy 1.58.1;
why?
#include <Arduino.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include "Audio.h"
const char* ssid = "SmS_jiofi";
const char* password = "sms123458956";
const char* chatgpt_token = "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";
const char* temperature = "0";
const char* max_tokens = "45";
String Question = "";
#define I2S_DOUT 25
#define I2S_BCLK 27
#define I2S_LRC 26
Audio audio;
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.disconnect();
while (!Serial);
// wait for WiFi connection
WiFi.begin(ssid, password);
Serial.print("Connecting to ");
Serial.println(ssid);
while (WiFi.status() != WL_CONNECTED)
{
delay(1000);
Serial.print(".");
}
Serial.println("connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
audio.setVolume(100);
}
void loop()
{
Serial.print("Ask your Question : ");
while (!Serial.available())
{
audio.loop();
}
while (Serial.available())
{
char add = Serial.read();
Question = Question + add;
delay(1);
}
int len = Question.length();
Question = Question.substring(0, (len - 1));
Question = "\"" + Question + "\"";
Serial.println(Question);
HTTPClient https;
//Serial.print("[HTTPS] begin...\n");
if (https.begin("https://api.openai.com/v1/completions")) { // HTTPS
https.addHeader("Content-Type", "application/json");
String token_key = String("Bearer ") + chatgpt_token;
https.addHeader("Authorization", token_key);
String payload = String("{\"model\": \"text-davinci-003\", \"prompt\": ") + Question + String(", \"temperature\": ") + temperature + String(", \"max_tokens\": ") + max_tokens + String("}"); //Instead of TEXT as Payload, can be JSON as Paylaod
//Serial.print("[HTTPS] GET...\n");
// start connection and send HTTP header
int httpCode = https.POST(payload);
// httpCode will be negative on error
// file found at server
if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
String payload = https.getString();
//Serial.println(payload);
DynamicJsonDocument doc(1024);
deserializeJson(doc, payload);
String Answer = doc["choices"][0]["text"];
Answer = Answer.substring(2);
Serial.print("Answer : "); Serial.println(Answer);
audio.connecttospeech(Answer.c_str(), "en");
}
else {
Serial.printf("[HTTPS] GET... failed, error: %s\n", https.errorToString(httpCode).c_str());
}
https.end();
}
else {
Serial.printf("[HTTPS] Unable to connect\n");
}
Question = "";
}
void audio_info(const char *info) {
Serial.print("audio_info: "); Serial.println(info);
}
Arduino: 1.8.19 (Windows 7), Board: "ESP32 Dev Module, Disabled, Disabled, Huge APP (3MB No OTA/1MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, Core 1, Core 1, None, Disabled"
In file included from C:\Users\HUA.DELLV-PC\Documents\Arduino\AudioOutpu_ChatGPT_M\AudioOutpu_ChatGPT_M.ino:9:
C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\Audio-master/Audio.h:31:2: error: #error "Teensyduino version 1.20 or later is required to compile the Audio library."
#error "Teensyduino version 1.20 or later is required to compile the Audio library."
^~~~~
In file included from C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\Audio-master/Audio.h:81,
from C:\Users\HUA.DELLV-PC\Documents\Arduino\AudioOutpu_ChatGPT_M\AudioOutpu_ChatGPT_M.ino:9:
C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\Audio-master/effect_delay.h:47:35: error: division by zero in #if
#define DELAY_QUEUE_SIZE (6144 / AUDIO_BLOCK_SAMPLES)
^
C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\Audio-master/effect_delay.h:109:5: note: in expansion of macro 'DELAY_QUEUE_SIZE'
#if DELAY_QUEUE_SIZE * AUDIO_BLOCK_SAMPLES < 65535
^~~~~~~~~~~~~~~~
In file included from C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\Audio-master/Audio.h:129,
from C:\Users\HUA.DELLV-PC\Documents\Arduino\AudioOutpu_ChatGPT_M\AudioOutpu_ChatGPT_M.ino:9:
C:\Users\HUA.DELLV-PC\Documents\Arduino\libraries\Audio-master/play_serialflash_raw.h:33:10: fatal error: SerialFlash.h: No such file or directory
#include <SerialFlash.h> // github.com/PaulStoffregen/SerialFlash/blob/master/SerialFlash.h
^~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board ESP32 Dev Module.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.