Freeswitch embedded python script, freeswitchpython

Source: Internet
Author: User

Freeswitch embedded python script, freeswitchpython

Operating System: debian8.5 _ x64

Freeswitch version: 1.6.8

Python version: 2.7.9

Enable the python Module

Install the python lib Library

apt-get install python-dev

Edit modules. conf and enable the python module:

languages/mod_python

Compile and install:

./configure && make && make install

Enable python support in modules. conf. xml;

Start freeswitch;

Test script API Test

Add test script:

File Path:/usr/local/freeswitch/scripts/test1.py

File Content:

import freeswitchdef fsapi(session,stream,env,args):    stream.write("hello")    freeswitch.consoleLog("info","test")

Console Test

freeswitch@debian8> python test1hello2016-09-06 23:06:09.069753 [NOTICE] mod_python.c:212 Invoking py module: test12016-09-06 23:06:09.069753 [DEBUG] mod_python.c:283 Call python script2016-09-06 23:06:09.069753 [INFO] switch_cpp.cpp:1360 test2016-09-06 23:06:09.069753 [DEBUG] mod_python.c:286 Finished calling python scriptfreeswitch@debian8>
APP Testing

File Path:/usr/local/freeswitch/scripts/testCall. py

File Content:

import freeswitchdef handler(session, args):    session.answer()    freeswitch.console_log("info","testCall")    session.streamFile("local_stream://moh")    freeswitch.msleep(3000)    session.hangup()

Add the following configuration to dialplan:

<extension name="python test script">        <condition field="destination_number" expression="^400123456$">            <action application="python" data="testCall"/>        </condition></extension>

Register the phone number, call 400123456 to hear the moh sound, and view the freeswitch console log.

Github address:

Bytes

Please add

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.