From 39377cb700edfddbebd3a036ad02216c92d81fff Mon Sep 17 00:00:00 2001 From: Matjaz Lipus Date: Fri, 12 Mar 2021 20:58:43 +0100 Subject: [PATCH 1/3] removed unused code --- src/Audio/Playback.cpp | 5 +---- src/Audio/silence.hpp | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Audio/Playback.cpp b/src/Audio/Playback.cpp index 526439e..246e781 100644 --- a/src/Audio/Playback.cpp +++ b/src/Audio/Playback.cpp @@ -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) { 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; From 757aaf17c06c338bb22fcf5307dadb3ad541711f Mon Sep 17 00:00:00 2001 From: Matjaz Lipus Date: Sat, 13 Mar 2021 22:41:59 +0100 Subject: [PATCH 2/3] removed playback volume --- src/Audio/Playback.cpp | 9 ++------- src/Audio/Playback.h | 6 ------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/Audio/Playback.cpp b/src/Audio/Playback.cpp index 246e781..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) { @@ -105,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; }; From 08e19eef50513f41433f70545a699f1c1c86e1fd Mon Sep 17 00:00:00 2001 From: Matjaz Lipus Date: Sat, 13 Mar 2021 22:44:36 +0100 Subject: [PATCH 3/3] set only string end byte --- src/Speech/SpeechToIntent.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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;