<?xml version="1.0" encoding="UTF-8"?>
<alimrcp-server xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="alimrcp-server.xsd" version="1.0">
  <properties>
    <!--<ip type="auto"/>-->
    <!-- <ip type="iface">eth0</ip>-->
    <ip>0.0.0.0</ip>
    <!-- <ext-ip>a.b.c.d</ext-ip> -->
  </properties>

  <components>
    <resource-factory>
      <resource id="speechsynth" enable="true"/>
      <resource id="speechrecog" enable="true"/>
      <resource id="recorder"    enable="false"/>
      <resource id="speakverify" enable="false"/>
    </resource-factory>

    <!-- SofiaSIP MRCPv2 signaling agent -->
    <sip-uas id="SIP-Agent-1" type="SofiaSIP">
      <!-- By default, "ip" and "ext-ip" addresses, set in the properties, are used. These parameters can
        explicitly be specified per "sip-uas" by means of "sip-ip" and "sip-ext-ip" correspondingly. -->
      <!-- <sip-ip>10.10.0.1</sip-ip> -->
      <!-- <sip-ext-ip>a.b.c.d</sip-ext-ip> -->
      <sip-port>7010</sip-port>
      <sip-transport>udp,tcp</sip-transport>
      <!-- <force-destination>true</force-destination> -->
      <ua-name>UniMRCP SofiaSIP</ua-name>
      <sdp-origin>AliMrcpServer</sdp-origin>
      <!-- <sip-t1>500</sip-t1> -->
      <!-- <sip-t2>4000</sip-t2> -->
      <!-- <sip-t4>4000</sip-t4> -->
      <!-- <sip-t1x64>32000</sip-t1x64> -->
      <!-- default 600 = 5min, now 3 years-->>
      <sip-session-expires>189216000</sip-session-expires>
      <sip-min-session-expires>120</sip-min-session-expires>
      <!-- <sip-message-output>true</sip-message-output> -->
      <!-- <sip-message-dump>sofia-sip-uas.log</sip-message-dump> -->
      <!--  <mrcp-draft11-version>true</mrcp-draft11-version> -->
    </sip-uas>

    <!-- UniRTSP MRCPv1 signaling agent -->
    <rtsp-uas id="RTSP-Agent-1" type="UniRTSP">
      <rtsp-port>1554</rtsp-port>
      <resource-map>
        <param name="speechsynth" value="speechsynthesizer"/>
        <param name="speechrecog" value="speechrecognizer"/>
      </resource-map>
      <max-connection-count>100</max-connection-count>
      <inactivity-timeout>600</inactivity-timeout>
      <sdp-origin>AliMrcpServer</sdp-origin>
    </rtsp-uas>

    <!-- MRCPv2 connection agent -->
    <mrcpv2-uas id="MRCPv2-Agent-1">
      <!-- <mrcp-ip>10.10.0.1</mrcp-ip> -->
      <mrcp-port>1544</mrcp-port>
      <max-connection-count>300</max-connection-count>
      <max-shared-use-count>100</max-shared-use-count>
      <force-new-connection>true</force-new-connection>    <!-- 是否禁止连接复用,true表示禁止 -->
      <rx-buffer-size>1024</rx-buffer-size>                <!-- 表示接收到的MRCP消息的最大长度,超过则多次接收 -->
      <tx-buffer-size>1024</tx-buffer-size>                <!-- 表示发送时的MRCP消息的最大长度,超过则多次发送 -->
      <inactivity-timeout>600</inactivity-timeout>
      <termination-timeout>3</termination-timeout>
    </mrcpv2-uas>

    <media-engine id="Media-Engine-1">
      <realtime-rate>1</realtime-rate>
    </media-engine>

    <!-- Factory of RTP terminations -->
    <rtp-factory id="RTP-Factory-1">
      <rtp-port-min>10000</rtp-port-min>
      <rtp-port-max>20000</rtp-port-max>
    </rtp-factory>

    <!-- Factory of plugins (MRCP engines) -->
    <plugin-factory>
          <engine id="alimrcp-tts"       name="alimrcp_tts"    enable="true">
             <max-channel-count>100</max-channel-count>
             <param name="sdk-log-level"           value="5"/>
             <param name="sdm-metrics-host"        value="0.0.0.0:7009"/> <!-- 默认监听到本机所有ip上的7009端口, 可修改或置空(不监控) -->
             <param name="tts-save-audio"          value="0"/>   <!-- 默认不保存tts合成的录音, 如需保存则改为1 -->
             <param name="text-encoding-gb2312"    value="0"/>   <!-- 表示接收到ivr的合成文本编码方式, 默认为0, 即utf8, 如果是gb2312需修改该参数为1 -->
          </engine>
          <engine id="alimrcp-asr"      name="alimrcp_asr"    enable="true">
              <max-channel-count>100</max-channel-count>
              <param name="sdk-log-level"           value="5"/>
              <param name="sdm-metrics-host"        value="0.0.0.0:7009"/> <!-- 默认监听到本机所有ip上的7009端口, 可修改或置空(不监控) -->
              <param name="text-encoding-gb2312"    value="0"/>
              <param name="wav-uri-prefix"          value=""/>
              <param name="recognize-mode-continuous"  value="0"/>        <!-- 无需修改, 如要修改,建议同时修改sip-session-expires为一个无限大的值 -->
              <param name="no-input-timeout"        value="5000"/>        <!-- 无话超时时间, 单位毫秒, 不可过低, 如果ivr传递了, 则以ivr传递的为准 -->
              <param name="speech-complete-timeout" value="800"/>         <!-- vad尾点断句间隔, 单位毫秒, 范围[200,2000], 如果ivr传递了, 则以ivr传递的为准 -->
              <!--<param name="sensitivity-level"       value="0.2"/>-->         <!-- 噪音阈值参数、灵敏度参数,可以参考标准RFC协议,取值范围[-1,1],等同asr的speech_noise_threshold, -->
              <param name="speech-cache-count"      value="10"/>          <!-- should be greater than 0, suggest [1,20] -->
              <param name="save-waveform"           value="1"/>           <!-- 是否保存用户录音,默认保存,但还受IVR传参影响 -->
              <param name="ignore-ivr-save-waveform"    value="0"/>       <!-- 是否忽略IVR传递的save-waveform参数,默认不忽略,若要忽略请置为1 -->
              <param name="return-more-detail"      value="1"/>           <!-- 是否返回更多ASR相关信息, 默认返回 -->
              <param name="support-message-body"    value="0"/>           <!-- 当no-input-timeout或者no-match等状态时,是否返回消息体,默认没有-->
              <param name="force-stop-recognize"    value="1"/>
              <param name="xml-type"                value="application/nlsml+xml"/>
              <param name="asr-result-template"     value="../conf/asr_result_template.xml"/>
              <!--<param name="grammar-transformer"     value="../script/RequestTransformer.lua"/>-->
              <param name="script-when-hangup"      value="HangupNotifierDemo"/>     <!-- python script -->
              <param name="script-function-when-hangup"  value=""/>  <!-- function of python script -->
              <param name="script-of-nlu"           value="NluClientDemo"/>   <!-- nlu python script -->
              <param name="script-function-of-nlu"  value=""/>  <!-- nlu function of python script -->
         </engine>
    </plugin-factory>
  </components>

  <settings>
    <!-- RTP/RTCP settings -->
    <rtp-settings id="RTP-Settings-1">
      <jitter-buffer>
        <adaptive>1</adaptive>
        <playout-delay>50</playout-delay>
        <max-playout-delay>600</max-playout-delay>
        <time-skew-detection>1</time-skew-detection>
      </jitter-buffer>
      <ptime>20</ptime>
      <codecs own-preference="false">PCMU PCMA L16/96/8000 telephone-event/101/8000</codecs>
      <!-- Enable/disable RTCP support -->
      <rtcp enable="false">
        <!--
          RTCP BYE policies (RTCP must be enabled first)
            0 - disable RTCP BYE
            1 - send RTCP BYE at the end of session
            2 - send RTCP BYE also at the end of each talkspurt (input)
        -->
        <rtcp-bye>1</rtcp-bye>
        <!-- RTCP transmission interval in msec (set 0 to disable) -->
        <tx-interval>5000</tx-interval>
        <!-- Period (timeout) to check for new RTCP messages in msec (set 0 to disable) -->
        <rx-resolution>1000</rx-resolution>
      </rtcp>
    </rtp-settings>
  </settings>

  <profiles>
    <!-- MRCPv2 default profile -->
    <mrcpv2-profile id="uni2">
      <sip-uas>SIP-Agent-1</sip-uas>
      <mrcpv2-uas>MRCPv2-Agent-1</mrcpv2-uas>
      <media-engine>Media-Engine-1</media-engine>
      <rtp-factory>RTP-Factory-1</rtp-factory>
      <rtp-settings>RTP-Settings-1</rtp-settings>
    </mrcpv2-profile>

    <!-- MRCPv1 default profile -->
    <mrcpv1-profile id="uni1">
      <rtsp-uas>RTSP-Agent-1</rtsp-uas>
      <media-engine>Media-Engine-1</media-engine>
      <rtp-factory>RTP-Factory-1</rtp-factory>
      <rtp-settings>RTP-Settings-1</rtp-settings>
    </mrcpv1-profile>

  </profiles>
</alimrcp-server>