summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/codecs/wav.cpp2
-rw-r--r--src/tangara/audio/fatfs_stream_factory.cpp1
-rw-r--r--src/tangara/tts/player.cpp15
-rw-r--r--src/tangara/tts/player.hpp4
-rw-r--r--src/tangara/tts/provider.cpp13
5 files changed, 20 insertions, 15 deletions
diff --git a/src/codecs/wav.cpp b/src/codecs/wav.cpp
index f5b9d789..746f44ca 100644
--- a/src/codecs/wav.cpp
+++ b/src/codecs/wav.cpp
@@ -137,8 +137,6 @@ auto WavDecoder::OpenStream(std::shared_ptr<IStream> input, uint32_t offset)
// uint32_t file_size = bytes_to_u32(buffer_span.subspan(4, 4)) + 8;
std::string fmt_header = bytes_to_str(buffer_span.subspan(12, 4));
- ESP_LOGI(kTag, "fmt header found? %s",
- (fmt_header.starts_with("fmt")) ? "yes" : "no");
if (!fmt_header.starts_with("fmt")) {
ESP_LOGW(kTag, "Could not find format chunk");
return cpp::fail(Error::kMalformedData);
diff --git a/src/tangara/audio/fatfs_stream_factory.cpp b/src/tangara/audio/fatfs_stream_factory.cpp
index 735ec134..94f22ae9 100644
--- a/src/tangara/audio/fatfs_stream_factory.cpp
+++ b/src/tangara/audio/fatfs_stream_factory.cpp
@@ -50,7 +50,6 @@ auto FatfsStreamFactory::create(std::string path, uint32_t offset)
-> std::shared_ptr<TaggedStream> {
auto tags = tag_parser_.ReadAndParseTags(path);
if (!tags) {
- ESP_LOGE(kTag, "failed to read tags");
return {};
}
diff --git a/src/tangara/tts/player.cpp b/src/tangara/tts/player.cpp
index a803ce57..46e8c48a 100644
--- a/src/tangara/tts/player.cpp
+++ b/src/tangara/tts/player.cpp
@@ -31,11 +31,9 @@ Player::Player(tasks::WorkerPool& worker,
stream_playing_(false),
stream_cancelled_(false) {}
-auto Player::playFile(const std::string& path) -> void {
- ESP_LOGI(kTag, "playing '%s'", path.c_str());
-
+auto Player::playFile(const std::string& text, const std::string& file)
+ -> void {
bg_.Dispatch<void>([=, this]() {
- // Interrupt current playback
{
std::scoped_lock<std::mutex> lock{new_stream_mutex_};
if (stream_playing_) {
@@ -46,7 +44,7 @@ auto Player::playFile(const std::string& path) -> void {
stream_playing_ = true;
}
- openAndDecode(path);
+ openAndDecode(text, file);
if (!stream_cancelled_) {
events::Audio().Dispatch(audio::TtsPlaybackChanged{.is_playing = false});
@@ -56,10 +54,11 @@ auto Player::playFile(const std::string& path) -> void {
});
}
-auto Player::openAndDecode(const std::string& path) -> void {
+auto Player::openAndDecode(const std::string& text, const std::string& path)
+ -> void {
auto stream = stream_factory_.create(path);
if (!stream) {
- ESP_LOGE(kTag, "creating stream failed");
+ ESP_LOGW(kTag, "missing '%s' for '%s'", path.c_str(), text.c_str());
return;
}
@@ -67,7 +66,7 @@ auto Player::openAndDecode(const std::string& path) -> void {
// proper subset of 'low memory' decoders that can all be used for TTS
// playback.
if (stream->type() != codecs::StreamType::kWav) {
- ESP_LOGE(kTag, "stream was unsupported type");
+ ESP_LOGE(kTag, "'%s' has unsupported encoding", path.c_str());
return;
}
diff --git a/src/tangara/tts/player.hpp b/src/tangara/tts/player.hpp
index 47479007..d28da474 100644
--- a/src/tangara/tts/player.hpp
+++ b/src/tangara/tts/player.hpp
@@ -24,7 +24,7 @@ class Player {
public:
Player(tasks::WorkerPool&, drivers::PcmBuffer&, audio::FatfsStreamFactory&);
- auto playFile(const std::string& path) -> void;
+ auto playFile(const std::string& text, const std::string& path) -> void;
// Not copyable or movable.
Player(const Player&) = delete;
@@ -39,7 +39,7 @@ class Player {
std::atomic<bool> stream_playing_;
std::atomic<bool> stream_cancelled_;
- auto openAndDecode(const std::string& path) -> void;
+ auto openAndDecode(const std::string& text, const std::string& path) -> void;
auto decodeToSink(const codecs::ICodec::OutputFormat&,
std::unique_ptr<codecs::ICodec>) -> void;
};
diff --git a/src/tangara/tts/provider.cpp b/src/tangara/tts/provider.cpp
index 2b1dd4e6..d19500e0 100644
--- a/src/tangara/tts/provider.cpp
+++ b/src/tangara/tts/provider.cpp
@@ -49,9 +49,18 @@ auto Provider::feed(const Event& e) -> void {
// ESP_LOGI(kTag, "new selection: '%s', interactive? %i",
// ev.new_selection->description.value_or("").c_str(),
// ev.new_selection->is_interactive);
- std::string new_desc = ev.new_selection->description.value_or("");
+ auto text = ev.new_selection->description;
+ if (!text) {
+ ESP_LOGW(kTag, "missing description for element");
+ return;
+ }
+ auto file = textToFile(*text);
+ if (!file) {
+ return;
+ }
+
if (player_) {
- player_->playFile(textToFile(new_desc).value_or(""));
+ player_->playFile(*text, *file);
}
}
}