34 namespace speech = ::cogrob::cloud::speech;
37 int main(
int argc,
char *argv[]) {
38 google::InitGoogleLogging(argv[0]);
39 google::LogToStderr();
40 gflags::SetUsageMessage(
"PrintRMS utility for testing microphone.");
41 gflags::SetVersionString(
"1.0.0");
42 gflags::ParseCommandLineFlags(&argc, &argv,
true);
47 std::unique_ptr<AudioSample> sample = std::move(audio_queue.
blocking_pop());
48 double square_sum = 0;
49 for (
size_t i = 0; i < sample->size(); i += 2) {
50 int s = (
static_cast<int8_t
>((*sample)[i + 1])) << 8 | (*sample)[i];
53 double rms = std::sqrt(square_sum / (sample->size() / 2));
54 LOG(INFO) <<
"RMS: " << rms;
int main(int argc, char *argv[])
std::vector< uint8_t > AudioSample