2

I am trying to obtain an audio stream from call audio media to be able to send it to Speech-to-Text engine (to transcribe audio from streaming input). Any idea on how to achieve this?

Version info: pjlib 2.8-svn for POSIX

Thank you in advance.

Jakub
  • 21
  • 1
  • 3
  • Does this answer your question? [How to catch and translate incoming audio stream in other languages for an iOS Client app using PJSIP?](https://stackoverflow.com/questions/31023274/how-to-catch-and-translate-incoming-audio-stream-in-other-languages-for-an-ios-c) – Mišo Jun 17 '20 at 09:14
  • [Here](https://stackoverflow.com/questions/60164116/pjsip-capture-and-play-pcm-data/61979667#61979667) is an example with extracting decoded LPCM audio from the call – Islam Sabyrgaliyev Jun 18 '20 at 18:51

2 Answers2

0

I found a suggestion from the pjsip FAQ: https://trac.pjsip.org/repos/wiki/FAQ#audio-man

You can get real-time audio media by creating a new port, and find helpful information in ​mem_capture.c and wav_writer.c:

For sink only media ports, samples include:

  • mem_capture.c from pjmedia (media port to save audio to a buffer).
  • wav_writer.c from pjmedia (media port to save audio to a WAVE file).
Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
levanha
  • 21
  • 1
-1

using getAudioMedia() in onCallMediaState of Call class, we can get the AudioMedia of call, something like that(simple method in C++):

void SipCall::onCallMediaState(OnCallMediaStateParam &prm) {
    this->callInfo = getInfo();
    unsigned media_size = this->callInfo.media.size();
    for (unsigned i = 0; i < media_size; i++) { // ci.media.size()
        AudioMedia audioMedia = getAudioMedia(i);
        // do somthing with audio Media
        // example send to audio device:
        // AudDevManager& manager = Endpoint::instance().audDevManager();
        // audioMedia.startTransmit(manager.getPlaybackDevMedia());
        // do something....
    } 
}

Sorry, but i hope it can help something.

levanha
  • 21
  • 1
  • Thanks for the reply. However, this is not what I'm asking about. I know how to get audio media as it is in every tutorial. The problem is how to get stream of audio data (RTP or HTTP) from audio media to be able to send it to Speech-to-Text engine. – Jakub Aug 02 '19 at 08:24
  • i'm not sure, but you can see: "to catch the incoming audio stream could be to define REC_FILE in conference.c . For example: #define REC_FILE "/mypath/myname.pcm". PJSIP will store the frames unformatted (plain PCM data) in the given file. " Source: https://stackoverflow.com/questions/31023274/how-to-catch-and-translate-incoming-audio-stream-in-other-languages-for-an-ios-c?rq=1 – levanha Aug 05 '19 at 07:31