Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/soymatudev/Pokedex-Fleek/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The useDexterVoice hook provides text-to-speech (TTS) functionality for the PokéDex app, delivering Pokémon information in Spanish with a distinctive robotic voice character. It uses expo-speech to synthesize speech with custom voice parameters optimized for clarity and character.

Import

import { useDexterVoice } from '../../hooks/useDexterVoice';

Usage

const { hablarEntrada, detenerVoz } = useDexterVoice();

// Speak Pokémon information
hablarEntrada(
  "Este Pokémon de tipo fuego puede alcanzar temperaturas de 1200 grados.",
  "Charizard"
);

// Stop speech playback
detenerVoz();

Return Values

The hook returns an object with the following methods:

hablarEntrada(texto, nombrePokemon)

Speaks the provided text with the Pokémon’s name in Spanish using TTS. Parameters:
  • texto (string) - The Pokémon description or information to speak
  • nombrePokemon (string) - The name of the Pokémon
Behavior:
  • Cleans the text by removing form feed characters (\f)
  • Prepends the Pokémon name to the description
  • Speaks the combined message with configured Spanish voice settings
Example:
hablarEntrada(
  "Pokémon legendario que controla el tiempo atmosférico.",
  "Rayquaza"
);
// Speaks: "Rayquaza. Pokémon legendario que controla el tiempo atmosférico."

detenerVoz()

Stops any currently playing speech. Parameters: None Example:
detenerVoz();

Voice Configuration

The hook uses carefully tuned voice parameters to create a distinctive robotic/analytical character:
const options = {
  language: 'es-MX',                  // Spanish (Latin America)
  pitch: .57,                          // Higher pitch for robotic tone
  rate: 1.2,                           // Slightly faster for clarity
  voice: 'es-es-x-eea-network',       // Spanish voice identifier
};

Voice Parameters

  • language - 'es-MX' (Spanish - Mexico/Latin America)
  • pitch - 0.57 - Higher pitch for a robotic/juvenile character tone
  • rate - 1.2 - Slightly accelerated speed for analytical clarity
  • voice - 'es-es-x-eea-network' - Specific Spanish voice engine

Integration with expo-speech

This hook wraps the expo-speech library, which provides:
  • Cross-platform TTS support (iOS and Android)
  • Multiple language and voice options
  • Configurable speech parameters (pitch, rate, language)
  • Playback control (speak, stop)
For more details, see the expo-speech documentation.

Source Code

~/workspace/source/src/hooks/useDexterVoice.js
import * as Speech from 'expo-speech';

export const useDexterVoice = () => {
  const hablarEntrada = (texto, nombrePokemon) => {

    const textoLimpio = texto.replace(/\f/g, ' ');
    const mensajeCompleto = `${nombrePokemon}. ${textoLimpio}`;

    const options = {
      language: 'es-MX', // Español Latino
      pitch: .57,      // Un poco más agudo para ese toque robótico/juvenil
      rate: 1.2,       // Un poco más lento para claridad analítica
      voice: 'es-es-x-eea-network',
    };

    Speech.speak(mensajeCompleto, options);
  };

  const detenerVoz = () => {
    Speech.stop();
  };

  return { hablarEntrada, detenerVoz };
};

Best Practices

  • Call detenerVoz() before starting new speech to avoid overlapping audio
  • Clean text input to remove special characters that may affect pronunciation
  • Consider adding speech callbacks for handling completion events
  • Test voice parameters on both iOS and Android for consistent experience