@boruto_vk7/voice
v1.0.2
Published
Fork do @discordjs/voice otimizado para Termux. Usa @boruto_vk7/opus-ogg como engine de áudio. DAVE encryption (e2ee) é opcional.
Maintainers
Readme
@boruto_vk7/voice-ogg
Implementation of the Discord Voice API for Node.js, optimized for Termux.
This is a fork of @discordjs/voice that replaces prism-media with @boruto_vk7/opus-ogg as the primary audio engine.
Key Differences from @discordjs/voice
- No
prism-mediahard dependency: The audio pipeline uses@boruto_vk7/opus-oggfor Ogg Opus demuxing, eliminating the need forprism-mediaas a core dependency. - Termux Compatible: Designed to work in Android environments via Termux with minimal native dependencies.
- Lower Node.js requirement: Supports Node.js 18+ instead of 22.12.0+, making it compatible with more Termux setups.
- FFmpeg fallback: Includes a built-in
child_processfallback for FFmpeg, soffmpeg-staticis optional.
Features
- Send and receive audio in Discord voice-based channels
- A strong focus on reliability and predictable behavior
- Horizontal scalability with custom adapters
- A robust audio processing system powered by
@boruto_vk7/opus-ogg
Installation
npm install @boruto_vk7/voice-oggRequired Node.js: 18.0.0 or newer
Termux Setup:
pkg install nodejs ffmpeg
npm install @boruto_vk7/voice-oggDependencies
This library has several optional dependencies. Install one dependency from each category:
Encryption Libraries:
Only needed if your system does not support
aes-256-gcm.
npm install sodium
# or
npm install libsodium-wrappers
# or
npm install @noble/ciphersOpus Libraries:
npm install @discordjs/opus
# or
npm install opusscriptFFmpeg:
# Termux:
pkg install ffmpeg
# Other platforms - ensure ffmpeg is in PATH, or:
npm install ffmpeg-staticExamples
Basic Music Player
const { createAudioPlayer, createAudioResource, joinVoiceChannel, StreamType } = require('@boruto_vk7/voice-ogg');
const { EngineOgg, OggToOpusStream } = require('@boruto_vk7/opus-ogg');
// Join a voice channel
const connection = joinVoiceChannel({
channelId: 'CHANNEL_ID',
guildId: 'GUILD_ID',
adapterCreator: voiceAdapterCreator,
});
// Create an audio player
const player = createAudioPlayer();
// Create a resource using EngineOgg + OggToOpusStream
const oggStream = EngineOgg('https://example.com/audio.mp3', {
profile: 'audio',
forceStereo: true,
});
const opusStream = OggToOpusStream(oggStream);
const resource = createAudioResource(opusStream, {
inputType: StreamType.Opus,
});
// Play the resource
connection.subscribe(player);
player.play(resource);Local File Playback
const { createAudioResource, StreamType } = require('@boruto_vk7/voice-ogg');
// When you specify a file path, FFmpeg is used automatically
const resource = createAudioResource('./path/to/file.mp3');WhatsApp-Compatible Voice (Mono)
const { EngineOgg, OggToOpusStream } = require('@boruto_vk7/opus-ogg');
const { createAudioResource, StreamType } = require('@boruto_vk7/voice-ogg');
const oggStream = EngineOgg('input.mp3', {
profile: 'voip',
forceStereo: false, // Mono for WhatsApp iOS
});
const opusStream = OggToOpusStream(oggStream);
const resource = createAudioResource(opusStream, {
inputType: StreamType.Opus,
});API
This fork maintains the same public API as @discordjs/voice v0.19.2. All exports remain identical:
| Export | Description |
|--------|-------------|
| createAudioPlayer | Creates a new AudioPlayer |
| createAudioResource | Creates an AudioResource from input |
| joinVoiceChannel | Joins a Discord voice channel |
| StreamType | Enum for stream types |
| TransformerType | Enum for transformer types |
| demuxProbe | Probes a stream to detect its type |
| generateDependencyReport | Generates a dependency report |
| VoiceConnection | Voice connection class |
| AudioResource | Audio resource class |
| AudioPlayer | Audio player class |
License
MIT
Fork based on: @discordjs/voice v0.19.2 Audio Engine: @boruto_vk7/opus-ogg v1.2.2 Developed by: eduh_dev021 (Borutovk7)
