Clone your voice and build a Python voice agent in 100 lines

Tim clones his voice in AssemblyAI, then builds a Python agent that listens, thinks with an LLM and answers back in his cloned voice in under 100 lines of code.

Tech With Tim · YouTube · published Nov 13, 2026 · Automation & Agents

Clone your voice and build a Python voice agent in 100 lines — video by Tech With Tim▶ Watch on YouTube
Prompt
Write a Python voice agent in under 100 lines using AssemblyAI: record the mic until I press Enter, transcribe it, send the text plus conversation history to an LLM with a system prompt that keeps replies to 1-3 short spoken sentences, then speak the reply in my cloned voice ID, in a loop until I say goodbye.

Visual breakdown

Tim clones his own voice in AssemblyAI's dashboard, then builds a Python voice agent in under 100 lines: record the mic, transcribe it, send the text to an LLM, and stream the reply back out in the cloned voice.

The problem: Voice agents need speech-to-text, an LLM and text-to-speech working together, and you want the AI to sound like you rather than a stock voice.

How the voice agent works

  1. MicrophoneRecord from the computer's default input until you press Enter
  2. Save as WAVAssembly AI's transcriber expects a WAV file
  3. Speech to textAssembly AI transcribes the recording in the cloud
  4. LLMCalled through Assembly AI's LLM gateway with a system prompt and the full chat history
  5. Text to speechCloned voice ID speaks the reply, streamed chunk by chunk
  6. SpeakerAudio plays back through the sound device
InputsPlain codeAI serviceResult

Five steps of any voice agent

  1. Input from a microphone
  2. Speech to text
  3. LLM generates the answer
  4. Text to speech
  5. Play through a speaker

By the numbers

<100lines of code
$50free credits with the sponsor link
$0.04cost of all his testing
10-20 svoice sample to clone

Build your own

Sign up for a free Assembly AI account, clone a voice, then write the code in any editor (he uses Cursor).

  1. In the dashboard, open Text to Speech, then Voices, then Create voice clone, and record a 10 to 20 second sample
  2. Copy the new voice ID and your API key into a .env file
  3. Run uv init, then uv add assemblyai, httpx, python-dotenv and sounddevice
  4. Write listen(): record until Enter, save a WAV, transcribe it
  5. Write think(): send the text to the LLM gateway with a system prompt and keep the conversation history (max 200 tokens, 30 s timeout)
  6. Write speak(): open a text-to-speech session with your voice ID and stream the audio to the speaker
  7. Loop listen, think, speak, and quit on 'goodbye'

The free plan only unlocks one model (Qwen 3.5 in the video); any LLM from the gateway works with a paid account.

Tips from the video

  • Write the system prompt for spoken output: 1 to 3 short sentences, no markdown lists or emojis.
  • Test each step on its own (print listen, then think, then speak) before joining them.
  • Streaming the speech makes the reply start much faster than the non-streaming listening step.
  • Only clone voices you have permission to clone.
  • For lower latency or real receptionist or caller agents, he points to LiveKit as the more advanced option.

Distilled from the video’s captions

How to try it

  1. Open AssemblyAI.
  2. Copy the prompt and fill in the [placeholders].
  3. Watch Tech With Tim's video for the full walkthrough and setup.

Related use cases

Share