Categorygithub.com/alexperezortuno/go-audio
repository
0.0.0-20240823013223-88b240a5673a
Repository: https://github.com/alexperezortuno/go-audio.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# README

go-audio

Description

This is an application for recording and editing audio using the ffmpeg library. Additionally, it can convert text to audio in different languages.

CLI Options

FlagDefaultEnvironment VariableDescription
--help, -hshow help
--debugfalseOPEN_AUDIO_DEBUGDebug mode
-p, --playfalseOPEN_AUDIO_PLAYplay audio file in default player
-e, --encodefalseOPEN_AUDIO_ENCODEencode audio file with custom codec, bitrate and format
-t, --ttsfalseOPEN_AUDIO_TTSOption to generate text to speech
--recordfalseOPEN_AUDIO_RECORDrecord audio from microphone or board
-o, --outputaudioOPEN_AUDIO_OUTPUToutput file directory
-d, --duration5OPEN_AUDIO_DURATIONduration of recording in seconds
-r, --sample-rate44100OPEN_AUDIO_SAMPLE_RATEsample rate to use for recording audio
-c, --channels2OPEN_AUDIO_CHANNELSnumber of channels to use for recording audio
--devicemicrophoneOPEN_AUDIO_DEVICEdevice to record from, available devices: microphone, board
-f, --frames-per-buffer64OPEN_AUDIO_FRAMES_PER_BUFFERframes per buffer for recording audio
-s, --sentenceHello!OPEN_AUDIO_SENTENCEinput text to encode to speech
-l, --languageenOPEN_AUDIO_LANGUAGElanguage to use for text to speech, available languages: en, es, pt, fr, it, ru, de
-i, --input-fileOPEN_AUDIO_INPUT_FILEinput file to encode
--log_formattxtOPEN_AUDIO_LOG_FORMATlog format, available formats: txt, json
--codecpcm_s16leOPEN_AUDIO_CODECcodec to use for audio file, example codecs: pcm_s16le, pcm_s24le
--bitrate128kOPEN_AUDIO_BITRATEbitrate to use for audio file, example bitrates: 128k, 256k, 512k
--formatwavOPEN_AUDIO_FORMATformat to use for audio file, example formats: wav, mp3, ogg
--file-namerecordingOPEN_AUDIO_FILE_NAMEfile name to use for audio file

Requirements

sudo apt install portaudio19-dev
brew install ffmpeg       # macOS
sudo apt-get install ffmpeg  # Linux
go mod tidy

Run

go run cmd/main.go

Build

make build

Examples

./build/go_audio -t -p -l "en" -s "How are you?"
./build/go_audio -t -p -l "es" -s "¿En que puedo ayudarte?"
./build/go_audio -t -p -l "pt" -s "Muito longe, no entanto, que a estrada é muito longa."
./build/go_audio -t -p --format "mp3" --codec "libmp3lame" -i "audio/file_name_to_mp3.wav" -e

Test

make test