2.3.2 • Published 6 months ago

@zibot/ziextractor v2.3.2

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

ZiExtractor:

About

ZiExtractor is a personal music extractor built for extracting audio from various sources. It's currently under development and might not be entirely stable. Please use it with caution.
ZiExtractor draws inspiration from the @discord-player/extractor, providing a foundation for audio extraction.

Getting Started

Installation ZiExtractor

npm i @zibot/ziextractor

Integration

  1. Locate the main file where you initialize your discord-player (e.g., index.js).
  2. Import ZiExtractor from the ziextractor package:
const { ZiExtractor } = require("@zibot/ziextractor");
  1. Register ZiExtractor with your player:
player.extractors.register(ZiExtractor, {});
  1. Disable youtube
player.extractors.loadDefault((ext) => ext !== "YouTubeExtractor");

Important Notes

  • Exercise caution while using ZiExtractor as it's still under development.
  • Ensure you have the necessary permissions to extract audio from the intended sources.


ZiVoiceExtractor:

About

ZiVoiceExtractor is a powerful voice extraction and speech recognition tool designed for use with Discord bots. It allows you to capture voice input from users in voice channels and convert it to text using Google's Speech-to-Text API.

Getting Started

Initializing ZiVoiceExtractor

First, import the necessary components:

const { ZiVoiceExtractor, useZiVoiceExtractor } = require("@zibot/ziextractor");

Then, initialize the extractor with your Discord player instance and speech options:

const speechOptions = {
	ignoreBots: true,
	minimalVoiceMessageDuration: 1,
	lang: "en-US", // Set your preferred language
	key: "YOUR_GOOGLE_SPEECH_API_KEY", // Optional: Provide your own API key
	profanityFilter: false, // Optional: Enable/disable profanity filter
};
const voiceExtractor = useZiVoiceExtractor(speechOptions);

Handling Voice Input

To start processing voice input, you need to call the handleSpeakingEvent method when a user joins a voice channel:

which discord-player:

player.events.on("connection", async (queue) => {
	const { player, connection } = queue;
	const ziVoice = useZiVoiceExtractor();

	ziVoice.handleSpeakingEvent(player.client, connection);
});

which discord: joinVoiceChannel command:

const voiceChannel = interaction.member?.voice.channel;
if (voiceChannel) {
	joinVoiceChannel({
		channelId: voiceChannel.id,
		guildId: voiceChannel.guild.id,
		adapterCreator: voiceChannel.guild.voiceAdapterCreator,
		selfDeaf: false,
	});
}

voiceStateUpdate:

client.on("voiceStateUpdate", (oldState, newState) => {
	if (newState.channel && newState.channel.type === "voice") {
		const ziVoice = useZiVoiceExtractor();
		ziVoice.handleSpeakingEvent(client, newState);
	}
});

Handling Voice Output

To handle voice output, you can listen for the 'voiceCreate' event:

voiceExtractor.on("voiceCreate", async ({ content, user, channel, client }) => {
	console.log(`User ${user.username} said: ${content}`);
	// Handle the recognized speech here
});

Debugging

ZiVoiceExtractor provides debug information. You can listen to the 'debug' event for detailed logs:

voiceExtractor.on("debug", (message) => {
	console.log(`[ZiVoiceExtractor Debug] ${message}`);
});

Configuration Options

When initializing ZiVoiceExtractor, you can provide the following options:

  • ignoreBots: (boolean) Whether to ignore voice input from bots.
  • minimalVoiceMessageDuration: (number) Minimum duration of voice input to process (in seconds).
  • focusUser: (string) The user ID to focus on.
  • lang: (string) The language code for speech recognition (e.g., 'en-US', 'fr-FR').
  • key: (string) Your Google Speech API key (optional).
  • profanityFilter: (boolean) Whether to enable the profanity filter.

Notes

  • Ensure you have the necessary permissions to use voice features in your Discord bot.
  • The Google Speech API key is optional but recommended for production use to avoid rate limiting.
  • This extractor works best with clear audio input and may have difficulty with background noise or low-quality microphones.


TextToSpeech

Example: Ziji-bot-discord

Support

For issues, feature requests, or contributions, please visit the GitHub repository. Discord

2.3.2

6 months ago

2.3.1

6 months ago

2.3.0

6 months ago

2.2.2

6 months ago

2.2.1

7 months ago

2.2.0

7 months ago

2.1.8

7 months ago

2.1.7

7 months ago

2.1.9

7 months ago

2.1.6

9 months ago

2.1.5

9 months ago