unispeech / unimrcp

Open source cross-platform implementation of MRCP protocol
http://www.unimrcp.org
Apache License 2.0
379 stars 167 forks source link

Transcoding issue #285

Closed davidcsi closed 3 years ago

davidcsi commented 3 years ago

Hello,

I have a freeswitch with mod_unimrcp, the config is as follows:

<profile name="myserver" version="2">
  <param name="client-ip" value="10.15.139.5"/>
  <param name="client-port" value="25097"/>
  <param name="server-ip" value="asr.local.com"/>
  <param name="server-port" value="5060"/>
  <param name="sip-transport" value="udp"/>
  <param name="rtp-ip" value="$${local_ip_v4}"/>
  <param name="rtp-port-min" value="28000"/>
  <param name="rtp-port-max" value="29000"/>
  <param name="codecs" value="PCMA PCMU"/>
  <param name="rtcp" value="0"/>
  <param name="rtcp-bye" value="2"/>
  <param name="rtcp-tx-interval" value="5000"/>
  <param name="rtcp-rx-resolution" value="1000"/>
  <synthparams>
  </synthparams>
  <recogparams>
    <param name="start-input-timers" value="false"/>
  </recogparams>
</profile>

Only supports PCMA, but it seems the transcoding is not done right.

2021-02-09 19:47:10.347196 [INFO] mod_unimrcp.c:3140 asr_handle: name = unimrcp, codec = (null), rate = 16000, grammar = (null), param = (null)
2021-02-09 19:47:10.347196 [INFO] mod_unimrcp.c:3142 codec = L16, rate = 16000, dest = (null)
2021-02-09 19:47:10.407195 [INFO] mpf_bridge.c:93 () Media Path ASR-1 Source->[LPCM/8000/1]->Bridge->[LPCM/8000/1]->Encoder->[PCMA/8000/1]->Sink
2021-02-09 19:47:10.427967 [DEBUG] mod_unimrcp.c:1901 (ASR-1) RECOGNIZER channel is ready, codec = LPCM, sample rate = 8000

Can you give me a hand?

Thanks

davidcsi commented 3 years ago

So the problem seems to be that on src/switch_core_codec.c, when the codec is G.722, this is done:

codec_rate = !strcasecmp(codec->implementation->iananame, "g722")
                ? codec->implementation->samples_per_second : codec->implementation->actual_samples_per_second;

But it's not done on mod_unimrcp. This results in a sampling issue and garbles the audio going to the unimrcp server.

achaloyan commented 3 years ago

This issue seems to belong to mod_unimrcp in FreeSWITCH. There is no support for G.722 in the MPF library used by the client and server.