freedv-gui icon indicating copy to clipboard operation
freedv-gui copied to clipboard

[WIP] Initial support for piping audio through external vocoder programs.

Open tmiw opened this issue 1 year ago • 0 comments

Introduction

Add infrastructure so that external vocoders can be used. This is to support demoing of RADAE.

WARNING: This is experimental. You probably don't want to use this right now unless you're helping to test RADAE.

Setup

Linux/macOS

RADAE setup:

$ cd ~
$ git clone https://github.com/drowe67/radae
$ cd radae
$ python3 -m venv radae-venv
$ export PATH=`pwd`/radae-venv/bin:$PATH
$ pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
$ pip3 install matplotlib tqdm
$ mkdir build
$ cd build
$ cmake ..
$ make

freedv-gui:

$ cd ~
$ git clone https://github.com/drowe67/freedv-gui.git
$ cd freedv-gui
$ git checkout ms-external-vocoder
$ ./build_linux.sh [or ./build_osx.sh if on macOS]

Once compiled, go to Tools->Options->Modem and configure External Vocoder (shown below):

image

Each of these should be the full paths to radae_demo_rx.sh and radae_demo_tx.sh respectively. These scripts expect two arguments: the path to your RADAE folder and the path to the Python venv you set up. For example, /home/mooneer/freedv-gui/radae_demo_rx.sh /home/mooneer/radae /home/mooneer/radae/radae-venv.

Windows

  1. Download pre-built version from here and extract it somewhere on your hard drive. (For these instructions, we will assume it got extracted to C:\Users\User\Desktop, creating a folder on the desktop named FreeDV-1.9.10-devel-2024-08-23-37bc8434-windows-x86_64.)
  2. Install Python 3.12 from here. Make sure to check the checkbox to add python.exe to your PATH in the window that appears before proceeding with the installation.
  3. Download Miniconda from https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe and install it onto your computer.
  4. Go to Start->Anaconda prompt (miniconda3) and then enter the following commands. Make sure to note the "environment location" while you're running the commands; it should be something like C:\Users\User\miniconda3\envs\radae (where User is your username on your PC):
conda create -n radae
conda activate radae
conda install pytorch torchvision torchaudio cpuonly -c pytorch-nightly
conda install matplotlib

(Note: pip is not being used for Windows due to the version of NumPy having performance issues on that platform. The version of NumPy installed by conda uses a different "BLAS" library that is better optimized and is able to run RADAE in real time. Additionally, there is a bug in PyTorch 2.4.0 that affects performance in Windows, which is why we're using nightly builds instead.)

  1. Start freedv.exe in the FreeDV-1.9.10-devel-2024-08-23-37bc8434-windows-x86_64\bin folder and go to Tools->Options->Modem. Much like with Linux and macOS, you'll need to configure the RX and TX paths to point to radae_rx.bat and radae_tx.bat respectively (along with paths to the conda environment and RADAE). For example:
  • RX command: C:\Users\User\Desktop\FreeDV-1.9.10-devel-2024-08-23-37bc8434-windows-x86_64\bin\radae_rx.bat C:\Users\User\Desktop\FreeDV-1.9.10-devel-2024-08-23-37bc8434-windows-x86_64\radae C:\Users\User\miniconda3\envs\radae

  • TX command: C:\Users\User\Desktop\FreeDV-1.9.10-devel-2024-08-23-37bc8434-windows-x86_64\bin\radae_tx.bat C:\Users\User\Desktop\FreeDV-1.9.10-devel-2024-08-23-37bc8434-windows-x86_64\radae C:\Users\User\miniconda3\envs\radae

Usage

Once set up, you can then choose "External" from the list of modes in the main window and click Start. You should then be able to decode RADAE if you happen to receive a signal. TX should also work, either via the voice keyer or by simply pushing the PTT button.

Limitations:

  • FreeDV Reporter will show "unk" for your current TX mode. It should report when you TX, but it will not report any stations that you receive.
  • PSK Reporter may/may not show you as a listening FreeDV station but you definitely won't report anyone while using RADAE (for the same reasons as with FreeDV Reporter).
  • Multi-RX support does not work. You will have to push Stop, choose another mode and push Start again to go back to current/legacy FreeDV behavior.
  • Timing may not be 100% right yet (i.e. the ends of transmissions may be cut off). Add a bit more of a pause before ending PTT to mitigate this.

Additional Notes

Example of another way (on Linux) to test the scripts without transmitting OTA:

mooneer@ubuntu-vm:~/radae$ sox wav/mooneer.wav -t raw -b 16 -e signed-integer -L -c 1 -r 16000 - | ~/freedv-gui/radae_demo_tx.sh `pwd` `pwd`/radae-venv | ~/freedv-gui/radae_demo_rx.sh `pwd` `pwd`/radae-venv | aplay -f S16_LE -r 16000

tmiw avatar May 01 '24 03:05 tmiw