Freeswitch-soundtouch-变声开发

作者 : admin 本文共2467个字,预计阅读时间需要7分钟 发布时间: 2024-06-10 共1人阅读

文章目录

  • 一、介绍
  • 二、安装soundtouch
    • 2.1 源码安装方式(推荐)
      • 2.1.1下载源码
      • 2.1.2解压
      • 2.1.3 编译
      • 2.1.4 迁移(可选)
    • 2.2 apt-get 安装
  • 三、使用
    • 3.1 终端使用
    • 3.2 Freeswitch使用
      • 3.2.1编译Freeswitch的mod_soundtouch
      • 3.2.2启用 mod_soundtouch 模块
      • 3.3.3 使用
        • 使用api命令
        • 使用lua
        • 使用拨号计划
  • 四 问题
    • 4.1 没有变声,只有刺啦刺啦的声音

一、介绍

相关资料
Freeswitch关于soundtouch介绍

soundtouch下载

mod_soundtouch只有刺啦刺啦声音问题

FreeSWITCH使用soundtouch进行变声

二、安装soundtouch

我这里使用的环境docker是debian。其他环境也可以。

2.1 源码安装方式(推荐)

2.1.1下载源码

http://codeberg.org/soundtouch/soundtouch/tags

Freeswitch-soundtouch-变声开发插图
放到合适的位置,进行解压

2.1.2解压

tar -zxvf  soundtouch-2.3.3.tar.gz

Freeswitch-soundtouch-变声开发插图(1)

2.1.3 编译

cd soundtouch
./bootstrap 

默认的 debian 版本是用浮点样本编译的。
需要用整数样本重新编译它才能与 freeswitch 兼容。
--enable-integer-samples

./configure --enable-integer-samples
make
make install

2.1.4 迁移(可选)

我这里有两个环境,一个是编译环境,一个是运行环境,所以,我知道要吧这四个编译好的文件放到运行环境相同目录下面就可以。然后执行ldconfig,重新加载一下环境。
Freeswitch-soundtouch-变声开发插图(2)

2.2 apt-get 安装

 apt-get install libsoundtouch-dev libsoundtouch1 

三、使用

3.1 终端使用

1)变速不变调

soundstretch original.wav out30.wav -tempo=+30 # 加速,时常变短
soundstretch original.wav out30.wav -tempo=-30 # 减速,时常变长
2) 变调不变速

soundstretch original.wav pitch30.wav -pitch=+5 # 音调调高,可以将男声变成女声
soundstretch pitch30.wav normal.wav -pitch=-5 # 音调调低,可以将女声变成男声
3)变速且变调

soundstretch original.wav rate25.wav -rate=+25
Freeswitch-soundtouch-变声开发插图(3)
Freeswitch-soundtouch-变声开发插图(4)

3.2 Freeswitch使用

3.2.1编译Freeswitch的mod_soundtouch

首先进入源mod

cd freeswitch1_10_7/src/mod/applications/mod_soundtouch

make

make install

Freeswitch-soundtouch-变声开发插图(5)

可以在Freeswitch的生成环境下看到已经编译生成mod了
Freeswitch-soundtouch-变声开发插图(6)

3.2.2启用 mod_soundtouch 模块

在编译生成的Freeswitch目录下
/usr/local/freeswitch/conf/autoload_configs/modules.conf.xml
添加内容:
Freeswitch-soundtouch-变声开发插图(7)
然后重启

临时添加此mod,在fs_cli 执行load mod_soundtouch

3.3.3 使用

使用api命令

1)soundtouch命令格式

soundtouch  [start|stop] [send_leg] [hook_dtmf] [-]s [-]o p r t

soundtouch 参数说明:

  • uuid
    必选参数,需要进行变声操作leg的uuid
  • start|stop
    必选参数,使用start时,后面要跟参数,不能连续两次start,可以在同一个命令里面把所有参数都设置好。
    使用stop时,之前必须有start操作。
  • send_leg
    可选参数,
    不指定该参数时,用于该uuid发出去的音频变声(说的声音变声);
    指定该参数时,用于该uuid收到的音频变声(听的声音变声)。
  • hook_dtmf
    可选参数
    指定该参数时,在电话侧可用dtmf按键进行变声操作。如果指定,它将挂钩 DTMF 音调并根据底部的 DTMF 代码修改音高/速率/节奏
  • s
    以半音为单位调整音高,值应在 -14 到 14 之间,默认为 0
  • o
    以八度为单位调整音高,值应介于 -1 和 1 之间,默认为 0
  • p
    直接设置音调,值应> 0,默认1(较低=低音调)
  • r
    设置速率,值应大于 0,默认为 1(越低 = 越慢)
  • t
    设置节奏,值应大于 0,默认为 1(越低 = 越慢)

测试命令:

originate user/1001 &endless_playback(/usr/local/freeswitch/sounds/original.wav)
 
soundtouch uuid start send_leg 4s
soundtouch uuid  stop
soundtouch uuid  start send_leg -4s

Freeswitch-soundtouch-变声开发插图(8)

使用lua

例如,要在 Lua 中启动 soundtouch,请使用(这会将音调降低 0.2 个八度):

session:execute("soundtouch", "-0.2o") 

要将音调重置为正常,此方法将不起作用:

session:execute("soundtouch", "+0.2o") 

即使这样也行不通

session:execute("soundtouch", "0o") 

您需要通过以下命令明确“停止”soundtouch

session:execute("soundtouch","stop")

随后,您可以通过发出新的命令再次进行俯仰/速率变换,例如

session:execute("soundtouch","0.8r") 
使用拨号计划
 <action application="soundtouch" data="hook_dtmf -0.3o 0.8r"/>

四 问题

4.1 没有变声,只有刺啦刺啦的声音

我已经在这里回答过了
http://github.com/signalwire/freeswitch/issues/93
欢迎讨论18956043585
Freeswitch-soundtouch-变声开发插图(9)

本站无任何商业行为
个人在线分享 » Freeswitch-soundtouch-变声开发
E-->