NOTE:
This is an old article and has been superseded by the new Audio Daemon setup.
Quick Install
Create a directory for Ascalon file and run this command:
wget -N https://f002.backblazeb2.com/file/ascalon-cdn/ascalon-audio-setup.sh & \
chmod ug+x ascalon-audio-setup.sh & \
./ascalon-audio-setup.sh
This assumes that you have wget installed on your system.
The ascalon-audio-setup.sh script will perform the following steps:
- Make sure that OpenJDK11 java is installed.
- Download the required voicegain files.
Obtaining the Sender App and/or Daemon
These can be downloaded from the following location:
- Sender App: audio-stream-2.0.0-SNAPSHOT-jar-with-dependencies.jar
- Sender Daemon: audio-daemon-2.0.0-SNAPSHOT.jar
Java Runtime
Both of these are Java programs and will require java runtime to run (minimum version 11). You can get open source OpenJDK from e.g. adoptopenjdk.net, or you can get Java runtime from Oracle (may require license fee).
Both applications have very low requirements for memory and CPU resources. We have run them even on a tiny Raspbery Pi 3+ computer using only less then 10% CPU.
Java Heap and GC Settings
In order to run in an optimal way we have to tell Java Runtime to use specific settings related to Heap Memory size and Memory Garbage Collection. If default JVM settings are used some of the audio may be skipped because of Java pausing for Garbage Collection.
Here are the required settings:
- -XX:+UseConcMarkSweepGC
- -XX:+UseParNewGC
- -XX:NewRatio=2
- -Xms128m
- -Xmx128m
And here are some optional optimizations - probably overkill:
- -XX:ParallelGCThreads=4
- -XX:SurvivorRatio=8
- -XX:TargetSurvivorRatio=90
- -XX:MaxTenuringThreshold=15
If there are any issues with loss of audio, the GC behavior of Java can be examined by analyzing the GC logs. GC logs can be enabled using these properties:
- -Xloggc:gc-audio.log
- -XX:+PrintGCDetails
- -XX:+PrintGCTimeStamps
- -XX:+PrintGCApplicationStoppedTime
JSON Configuration File for the Sender
The configuration that does not need to change often is stored in a JSON file. Below is an example file with description of the fields.
{
"host" : "https://api.voicegain.ai",
"ws": "wss://cc.voicegain.ai/nats-websocket/port",
"jwt" : "eyJhbGciOiJIUzI1.....GCO70w",
"payloadWS" : {
"messages" : [
{
"text": "Transcription will start soon ...",
"tags": ["announce"]
}
]
} ,
"payloadASR" : {
"sessions": [{
"asyncMode" : "REAL-TIME",
"websocket": {
"name": "ACME",
"ifExists" : "kill"
},
"poll" : {
"afterlife" : 15000,
"persist" : 2592000000
}
}],
"audio": {
"source": {
"stream": {
"protocol": "ASCALON",
"controlWebsocket": "ACME"
}
},
"rate" : 16000
},
"settings": {
"preemptible" : false,
"asr": {
"langModel" : "d43f2cfe-aexx-4a93-a403-a0daxx528e61",
"noInputTimeout" : 59999,
"incompleteTimeout" : 3599999
}
}
}
}
}
Running Sender App
Sender App can stream audio obtained either from a file or from an audio device. More details about the Audio Sender App can be found here Command Line options for Audio Sender Client
Streaming Audio From a File
An example command to do this is:
java -Xloggc:gc-audio-sender-5.log -XX:NewRatio=2 -XX:ParallelGCThreads=4 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=15 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCApplicationStoppedTime -Xms192m -Xmx192m -jar audio-stream-2.0.0-SNAPSHOT-jar-with-dependencies.jar --file my-audio.wav --real --log info --json AudioSenderClient-CBC.json
Streaming Audio From a Device
An example command to do this is:
java -Xloggc:gc-audio-sender-5.log -XX:NewRatio=2 -XX:ParallelGCThreads=4 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=15 -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCApplicationStoppedTime -Xms192m -Xmx192m -jar audio-stream-2.0.0-SNAPSHOT-jar-with-dependencies.jar --source 2 --log info --json AudioSenderClient-CBC.json
Comments
0 comments
Please sign in to leave a comment.