Clone a voice from audio sample. Use for: custom voice, brand voice, personalized TTS
Clone a voice by uploading audio samples to ElevenLabs. Returns a voice_id usable with /pocket-knife:elevenlabs-tts and /pocket-knife:elevenlabs-voice-changer.
Ask the user for:
Important: Audio quality requirements for good cloning results:
Then run the following steps:
Step 1 - Check API key and file:
if [ -z "$ELEVENLABS_API_KEY" ]; then
echo "ERROR: ELEVENLABS_API_KEY not set."
echo "Run /pocket-knife:setup to configure your API keys."
exit 1
fi
VOICE_NAME="[VOICE_NAME_HERE]"
SAMPLE_FILE="[ABSOLUTE_PATH_TO_SAMPLE_FILE]"
DESCRIPTION="${DESCRIPTION:-}"
if [ ! -f "$SAMPLE_FILE" ]; then
echo "ERROR: Sample file not found: $SAMPLE_FILE"
echo "Provide an absolute path to an existing audio file."
exit 1
fi
Step 2 - Upload voice sample and create clone:
# Source: https://elevenlabs.io/docs/api-reference/voices/add
# Use --fail-with-body (NOT -f) - response is JSON with voice_id
DESC_FLAG=""
if [ -n "$DESCRIPTION" ]; then
DESC_FLAG="-F description=${DESCRIPTION}"
fi
RESPONSE=$(curl --fail-with-body -s \
-X POST "https://api.elevenlabs.io/v1/voices/add" \
-H "xi-api-key: $ELEVENLABS_API_KEY" \
-F "name=${VOICE_NAME}" \
-F "files=@${SAMPLE_FILE}" \
-F "remove_background_noise=false" \
$DESC_FLAG)
if [ $? -ne 0 ]; then
echo "ERROR: ElevenLabs Voice Cloner API call failed."
echo "Response: $RESPONSE"
echo "Check that ELEVENLABS_API_KEY is correct in ~/.claude/.env"
echo "Run /pocket-knife:setup to reconfigure."
exit 1
fi
Step 3 - Extract and display voice_id:
echo "$RESPONSE" | python3 -c "
import sys, json