add portaudio for reading microphones (#55)

This commit is contained in:
Fangjun Kuang
2023-02-22 17:13:07 +08:00
committed by GitHub
parent 124384369a
commit a65dcf77b3
6 changed files with 293 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
// sherpa-onnx/csrc/microphone.cc
//
// Copyright (c) 2022-2023 Xiaomi Corporation
#include "sherpa-onnx/csrc/microphone.h"
#include <stdio.h>
#include <stdlib.h>
#include "portaudio.h" // NOLINT
namespace sherpa_onnx {
Microphone::Microphone() {
PaError err = Pa_Initialize();
if (err != paNoError) {
fprintf(stderr, "portaudio error: %s\n", Pa_GetErrorText(err));
exit(-1);
}
}
Microphone::~Microphone() {
PaError err = Pa_Terminate();
if (err != paNoError) {
fprintf(stderr, "portaudio error: %s\n", Pa_GetErrorText(err));
exit(-1);
}
}
} // namespace sherpa_onnx