wx voice
1.0.0
แปลงไฟล์เสียงระหว่างแอพ Tencent (Weixin / Wechat, QQ) และ Silk codec ด้วยรูปแบบทั่วไปอื่น ๆ เช่น MP3 และ M4A
中文版
$ npm install wx-voice --save
$ npm install wx-voice -g
$ wx-voice compile
wx-voice <command> <options>
Example:
$ wx-voice decode -i input.silk -o output.mp3 -f mp3
$ wx-voice encode -i input.mp3 -o output.silk -f silk
Command:
decode decode to general audio format
encode encode from general audio format
compile compile wx-voice library
clean remove compiled library
Options:
-i <input> input file path
-o <output> output file path
-f <format> format of the output file
--bitrate bitrate of the output file
--frequency frequency of the output file
--channels channels of the output file
// Initialize
const WxVoice = require ( 'wx-voice' ) ;
var voice = new WxVoice ( ) ;
// Error handler
voice . on ( "error" , ( err ) => console . log ( err ) ) ;
// Decode silk to MP3
voice . decode (
"input.silk" , "output.mp3" , { format : "mp3" } ,
( file ) => console . log ( file ) ) ;
// Output: "/path/to/output.mp3"
เริ่มต้นวัตถุ wxVoice
พารามิเตอร์ | คำอธิบาย |
---|---|
tempFolder | โฟลเดอร์ของไฟล์ชั่วคราว ค่าเริ่มต้นคือระบบชั่วคราว |
ffmpegPath | เส้นทางที่กำหนดเองไปยังไฟล์ปฏิบัติการ ffmpeg ค่าเริ่มต้นคือ $PATH |
ถอดรหัสเสียงเป็นรูปแบบทั่วไป
เข้ารหัสเสียงเป็นรูปแบบ Silk/webm
พารามิเตอร์ | คำอธิบาย |
---|---|
ป้อนข้อมูล | อินพุตเส้นทางเสียง |
เอาท์พุท | เส้นทางเสียงเอาท์พุต |
ตัวเลือก | ตัวเลือกเอาต์พุต (วัตถุ JS) โปรดดูตัวเลือก |
โทรกลับ | โทรกลับโดยมี output เป็นพารามิเตอร์เมื่อถอดรหัสสำเร็จ undefined เป็นอย่างอื่น |
voice . encode (
"input.mp3" , "output.silk" , { format : "silk" } ,
( file ) => console . log ( file ) ) ;
// Output: "/path/to/output.silk"
รับระยะเวลาของไฟล์เสียง
(ถอดรหัสเป็นรูปแบบเสียงทั่วไปก่อนเรียกใช้วิธีนี้)
พารามิเตอร์ | คำอธิบาย |
---|---|
filePath | เส้นทางไฟล์ไปยังเสียง |
โทรกลับ | โทรกลับโดยมีระยะเวลาของเสียงเป็นวินาทีเป็นพารามิเตอร์เมื่อถอดรหัสสำเร็จ มิฉะนั้น 0 |
voice . encode ( "output.mp3" , ( dur ) => console . log ( dur ) ) ;
// Output: "10.290"
Javascript Object เพื่อตั้งค่าตัวเลือกสำหรับไฟล์เอาต์พุต
พารามิเตอร์ | คำอธิบาย |
---|---|
รูปแบบ | รูปแบบที่จะเข้ารหัส/ถอดรหัส (silk, webm, mp3, m4a...) การแยกวิเคราะห์เริ่มต้นจากเอาต์พุต |
บิตเรต | บิตเรตของเอาต์พุต หน่วย bps |
ความถี่ | ความถี่ของเอาท์พุต หน่วย Hz |
ช่อง | ช่องสัญญาณเอาต์พุตเริ่มต้นที่ 1 |
ถอดรหัส: ทดสอบกับ mp3
, m4a
, wav
, pcm
เข้ารหัส: ทดสอบบน silk
, silk_amr
, webm
ระบบปฏิบัติการ | สั่งการ |
---|---|
อูบุนตู | sudo apt-get install build-essential |
CentOS | sudo yum groupinstall 'Development Tools' |
แม็ค | ดาวน์โหลด XCode.dll |
$ sudo add-apt-repository ppa:mc3man/trusty-media
$ sudo apt-get update
$ sudo apt-get install ffmpeg
$ sudo yum install epel-release
$ sudo yum update
$ sudo rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
สำหรับ CentOS 7:
$ sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
สำหรับ CentOS 6:
$ sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-2.el6.nux.noarch.rpm
ติดตั้ง FFMPEG:
$ sudo yum install ffmpeg
$ brew install ffmpeg
MIT © อ่าง YC