Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/audio/speech_to_text/s2t_calculator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ class S2tCalculator : public CalculatorBase {
}
try {
if (payload.multipartParser->hasParseError())
return absl::InvalidArgumentError("Failed to parse multipart data");
return absl::InvalidArgumentError("Failed to parse multipart .");

std::string_view stream = payload.multipartParser->getFieldByName("stream");
if (!stream.empty()) {
return absl::InvalidArgumentError("streaming is not supported");
return absl::InvalidArgumentError("Streaming is not supported.");
}
std::string_view file = payload.multipartParser->getFileContentByFieldName("file");
if (file.empty()) {
return absl::InvalidArgumentError(absl::StrCat("File parsing fails"));
return absl::InvalidArgumentError(absl::StrCat("File parsing failed."));
}

std::vector<float> rawSpeech;
Expand All @@ -130,7 +130,7 @@ class S2tCalculator : public CalculatorBase {
SPDLOG_DEBUG("Received file format: mp3");
}
} catch (std::exception&) {
return absl::InvalidArgumentError("Received input file is not valid wav nor mp3 audio file");
return absl::InvalidArgumentError("Received input file is not valid wav nor mp3 audio file.");
}
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
Expand All @@ -154,10 +154,10 @@ class S2tCalculator : public CalculatorBase {
config.return_timestamps = true;
} else if (timestampsType == "word") {
if (!pipe->enableWordTimestamps)
return absl::InvalidArgumentError("Word timestamps not supported for this model");
return absl::InvalidArgumentError("Word timestamps not supported for this model.");
config.word_timestamps = true;
} else {
return absl::InvalidArgumentError("Invalid timestamp_granularities type. Allowed types: \"segment\", \"word\"");
return absl::InvalidArgumentError("Invalid timestamp_granularities type. Allowed types: \"segment\", \"word\".");
}
}
std::string temperature = payload.multipartParser->getFieldByName("temperature");
Expand Down
6 changes: 3 additions & 3 deletions src/audio/text_to_speech/t2s_servable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ static ov::Tensor read_speaker_embedding(const std::filesystem::path& file_path)
throw std::runtime_error("File size is not a multiple of float size.");
}
size_t num_floats = buffer_size / sizeof(float);
if (num_floats != 512) {
throw std::runtime_error("File must contain speaker embedding including 512 32-bit floats.");
}
// if (num_floats != 512) {
// throw std::runtime_error("File must contain speaker embedding including 512 32-bit floats.");
// }

ov::Tensor floats_tensor(ov::element::f32, ov::Shape{1, num_floats});
input.read(reinterpret_cast<char*>(floats_tensor.data()), buffer_size);
Expand Down
27 changes: 24 additions & 3 deletions src/test/audio/speech2text_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,28 @@ TEST_F(Speech2TextHttpTest, invalidFile) {
status.getCode(),
ovms::StatusCode::MEDIAPIPE_EXECUTION_ERROR);
std::string expectedMsg = "Mediapipe execution failed. MP status - INVALID_ARGUMENT: CalculatorGraph::Run() failed: \n"
"Calculator::Process() for node \"S2tExecutor\" failed: File parsing fails";
"Calculator::Process() for node \"S2tExecutor\" failed: File parsing failed.";
EXPECT_EQ(status.string(), expectedMsg);
}

TEST_F(Speech2TextHttpTest, invalidStreamTrue) {
auto req = drogon::HttpRequest::newHttpRequest();
req->setMethod(drogon::Post);
req->addHeader("content-type", "multipart/form-data; boundary=\"12345\"");
std::string stream = "\r\n"
"Content-Disposition: form-data;name=\"stream\"\r\n"
"\r\n"
"true\r\n"
"--12345";
req->setBody(Speech2TextHttpTest::body + stream);
std::shared_ptr<MultiPartParser> multiPartParserWithRequest = std::make_shared<DrogonMultiPartParser>(req);
std::string requestBody = "";
auto status = handler->dispatchToProcessor(endpoint, requestBody, &response, comp, responseComponents, writer, multiPartParserWithRequest);
ASSERT_EQ(
status.getCode(),
ovms::StatusCode::MEDIAPIPE_EXECUTION_ERROR);
std::string expectedMsg = "Mediapipe execution failed. MP status - INVALID_ARGUMENT: CalculatorGraph::Run() failed: \n"
"Calculator::Process() for node \"S2tExecutor\" failed: Streaming is not supported.";
EXPECT_EQ(status.string(), expectedMsg);
}

Expand Down Expand Up @@ -338,7 +359,7 @@ TEST_F(Speech2TextHttpTest, invalidTimestampType) {
status.getCode(),
ovms::StatusCode::MEDIAPIPE_EXECUTION_ERROR);
std::string expectedMsg = "Mediapipe execution failed. MP status - INVALID_ARGUMENT: CalculatorGraph::Run() failed: \n"
"Calculator::Process() for node \"S2tExecutor\" failed: Invalid timestamp_granularities type. Allowed types: \"segment\", \"word\"";
"Calculator::Process() for node \"S2tExecutor\" failed: Invalid timestamp_granularities type. Allowed types: \"segment\", \"word\".";
EXPECT_EQ(status.string(), expectedMsg);
}

Expand All @@ -359,6 +380,6 @@ TEST_F(Speech2TextHttpTest, emptyTimestampType) {
status.getCode(),
ovms::StatusCode::MEDIAPIPE_EXECUTION_ERROR);
std::string expectedMsg = "Mediapipe execution failed. MP status - INVALID_ARGUMENT: CalculatorGraph::Run() failed: \n"
"Calculator::Process() for node \"S2tExecutor\" failed: Invalid timestamp_granularities type. Allowed types: \"segment\", \"word\"";
"Calculator::Process() for node \"S2tExecutor\" failed: Invalid timestamp_granularities type. Allowed types: \"segment\", \"word\".";
EXPECT_EQ(status.string(), expectedMsg);
}