diff --git a/src/Audio/Playback.cpp b/src/Audio/Playback.cpp index 526439e..865329b 100644 --- a/src/Audio/Playback.cpp +++ b/src/Audio/Playback.cpp @@ -20,7 +20,7 @@ void PlaybackImpl::begin(I2S* i2s) out->SetPinout(16, 27, 4); out->SetChannels(1); out->SetOutputModeMono(1); - out->SetGain(volume); + out->SetGain(0.4); } void PlaybackImpl::loop(uint _time) { @@ -63,10 +63,7 @@ void PlaybackImpl::playMP3(AudioFileSource* _file) i2s->begin(); delay(50); file = _file; - if(!mp3->begin(file, out)) - { - return; - } + mp3->begin(file, out); } void PlaybackImpl::playMP3(const char* path) { @@ -108,12 +105,7 @@ void PlaybackImpl::setPlaybackDoneCallback(void (*callback)()) if(callback == nullptr || !isRunning()) return; playbackDoneCallback = callback; } -void PlaybackImpl::setVolume(float vol) +void PlaybackImpl::setVolume(float volume) { - volume = vol; out->SetGain(volume); -} -float PlaybackImpl::getVolume() -{ - return volume; } \ No newline at end of file diff --git a/src/Audio/Playback.h b/src/Audio/Playback.h index f59beea..d7abba4 100644 --- a/src/Audio/Playback.h +++ b/src/Audio/Playback.h @@ -52,11 +52,6 @@ class PlaybackImpl : public LoopListener * @param vol Volume, float from 0.0 to 4.0; */ void setVolume(float vol); - /** - * Gets playback volume. - * @return Volume, float from 0.0 to 4.0; - */ - float getVolume(); void loop(uint _time) override; bool isRunning(); @@ -67,7 +62,6 @@ class PlaybackImpl : public LoopListener AudioOutputI2S *out; AudioFileSource *file; void(*playbackDoneCallback)(); - float volume = 0.4; }; diff --git a/src/Audio/silence.hpp b/src/Audio/silence.hpp index d482281..3f38ad6 100644 --- a/src/Audio/silence.hpp +++ b/src/Audio/silence.hpp @@ -58,4 +58,3 @@ unsigned char silence[] = PROGMEM { 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 }; -unsigned int _home_cm_Downloads_silence_mp3_len = 690; diff --git a/src/Speech/SpeechToIntent.cpp b/src/Speech/SpeechToIntent.cpp index 6fc39e4..0ac1a10 100644 --- a/src/Speech/SpeechToIntent.cpp +++ b/src/Speech/SpeechToIntent.cpp @@ -122,7 +122,7 @@ IntentResult* SpeechToIntentImpl::identifyVoice(const char* filename){ const char* transcript = json["text"].as(); uint32_t transcriptLength = strlen(transcript); result->transcript = static_cast(malloc(transcriptLength + 1)); - memset(result->transcript, 0, transcriptLength+1); + memset(result->transcript + transcriptLength, 0, 1); memcpy(result->transcript, transcript, transcriptLength); const char* intent; @@ -137,7 +137,7 @@ IntentResult* SpeechToIntentImpl::identifyVoice(const char* filename){ uint32_t intentLength = strlen(intent); result->intent = static_cast(malloc(intentLength + 1)); - memset(result->intent, 0, intentLength+1); + memset(result->intent + intentLength, 0, 1); memcpy(result->intent, intent, intentLength); if(!json.containsKey("entities")) return result;