๐ŸŽ™๏ธBuild An AI Voice Agent With DeepSeek R1 (Python)

AssemblyAI ยท Beginner ยท๐Ÿง  Large Language Models ยท1y ago

Key Takeaways

Build an AI voice agent using DeepSeek R1 model with AssemblyAI API, AMA, and 11 Labs for real-time speech to text and text to speech functionality. The project utilizes Python and various libraries such as PortAudio for audio streaming.

Full Transcript

in this video I'll show you how to build an AI voice agent in Python using deep seeks R1 model since the R1 model has reasoning capabilities you'll see in our demo that the model actually explains its Chain of Thought on how it came to an answer or conclusion this is extremely useful when it comes to solving difficult problems whether it's a coding challenge or a math problem because the model is actually able to understand how it came to a solution and also go back and think if it made any mistakes this actually makes it more smarter than regular large language models I'm traveling to Paris next week what are some things that I should see okay so the user is planning a trip to Paris and wants to know what to see H I need to provide a good list of must-see attractions without being too long first off Paris has iconic landmarks like the Eiffel Tower and the Lou Museum those are pretty much must visits for anyone there then there's Versailles with its Grand Gardens this AI voice MoDOT is super easy to build the link to the GitHub repository will be in the description box below so let's get started the first thing we want to do is sign up for a free assembly AI API key you can find the link in the GitHub repository and also in the description box below for this YouTube video we'll be using assembly AI for realtime speech to text in order to transcribe what we're saying in real time after you've created your assembly AI API key the next thing you want to do is download AMA you you can do that by going onto their website once you're on ama's website all you have to do is download it once you've downloaded olama onto your local machine we can then move on to the next step which is signing up for 11 Labs we will be using 11 labs for text to speech so that's why we need that next we want to install Port audio now Port audio already comes pre-installed in Windows but if you have Linux or Mac you would need to install it so these are the commands for installing it for both of both of those devices what I've done is I've actually created a virtual python environment so what I'm going to do is just paste this into terminal after that we want to actually go ahead and install a few different python libraries so we want to install assembly AI of course we're going to be using it for real time speech to text Hama because we actually want to command and select different types of models and run it um and then 11 labs for of course speech to text so you can run all of these commands in your terminal lastly if you're on Mac you also want to install MVP for audio streaming so that we can play out our audio output from what 11 Labs gives us so you can do that by doing Brew install MVP in terminal as well once you have done all of this what you can do is now download or pull our deep seek R1 model from olama now in order to do this what you have to do is run the following commands keep in mind that for this tutorial I will be running the Deep seek R1 7B model but if you want to try something else feel free to do that so now I have successfully downloaded the Deep seek R1 model and then now we can get started writing our code the first thing we're going to do is import all the library set we have downloaded so for example assembly AI 11 labs and AMA next we will create a class called AI voice agent the first thing we want to do is set up our assembly AI API key so right here is where you would include your own assembly a API key which you can find in your user dashboard once you log into assembly ai's website next we'll also Define our 11lbs API key similarly you would replace this entire thing with your 11 Labs API key as a string after that I'm going to create an empty transcriber object and I'm going to sent it to none and what this eventually will contain is our realtime transcriber after that I'm also creating a transcript object which will contain multiple transcripts as we continue talking with the AI agent but essentially the initial part of the transcript is containing a prompt to uh deep seek R1 just saying that you are a language model called R1 created by Deep seek answer the questions being asked in less than 300 characters and as we're chatting with this AI voice agent what we're going to do is append what we're saying to this full transcript as well as what the AI agent is saying so that way our AI agent or large language model always has a full context of what has been said by it and us next we're going to define a start transcription method which will create a realtime transcriber object using assembly AI as well as communicate with assembly ai's API so the first thing we do is Define a realtime transcriber object in that we're going to set a couple of parameters first off we're setting the sample rate to 16,000 now this is the default value after that we're also setting a couple of different methods on data on error on open and on close essentially all of these are methods which Define how our real-time transcriber should be behaving when each of these events happen so we'll be defining that in a short while next what we're also doing is within this trans uh start transcription method what we're doing is we are connecting the transcriber so once we have defined it we're also connecting it and then we are creating a microphone stream from assembly ai's API after the start transcription method we're also going to define a stop transcription method all this does is it's that's the transcriber object that we initially created To None back again back to its original state we will be calling this stop transcription method anytime we want our real time transcriber to stop listening after that we're going to define a series of methods which I talked about earlier which is all of these four methods which are required for the transcriber object so we're going to start off with on open all we're doing here is returning we're not doing anything but but the default behavior is printing out the real time transcriber session ID the on data method contains a very important part of the logic behind our AI voice agent as you speaking this method is constantly receiving uh partial transcripts as well as final transcripts from assembly ai's API first off what are partial transcripts so partial transcripts are just words as you're talking so they're individual words meanwhile a final transcript is often times an entire sentence or essentially whatever you have said without taking a break of longer than 700 milliseconds the moment you take that 700 milliseconds break when you pause that is going to be considered a final transcript and that's going to be sent to this method as well this method behaves very differently based on what type of transcript it has received if it receives a partial transcript basically a single word as you're talking it's not going to do anything it's just going to print it but the moment it receives a final transcript which kind of signals that the user has stopped talking and has taken a long pause it also signifies that hey the question has been completely said and now you can send that question to the large language model at this point what we do is we call the generate AI response method which will be defining later on now this generate AI response method is where we will send this transcript rpt that full transcript of whatever you have said of that entire question and then we send it to deep seeks R1 model before we Define the generate AI response method we also want to define the final two methods which are required for our real-time transcriber which is on error and on close next we're going to start defining our generate AI response method the first thing we want to do in this method when it's called is actually stop transcription so we want our realtime transcriber to stop listening momentarily while we send our real-time transcript to the large language model so now back to our full transcript which we Define at the very top what we're doing is now we're appending our current real-time transcript basically the question that you the user has said or asked and then we are just printing that out now at this point we're going to send this transcript to deep seek R1 using Ama so in order to communicate with deep seek R1 we're going to be making use of AMA we're calling the chat method and to that we have to pass a couple of parameters first off the model name so in this case deep seek R1 7B and then the messages so in messages we're going to be passing the full transcript that we defined and for stream we're going to set that to true now what we're doing is taking the AMA string which contains the response from the deep SE R1 model and then we're actually going to pass that to 11 Labs so what LLS is going to do is generate an audio stream by converting this text into speech once we have that audio stream we're going to start playing that out so that that is what this method right here does and this is the point where you hear the text to speech at the end of all this we're also going to be appending what deep seek R1 said back to the full transcript which contains the Full context of this conversation and then we're also going to start transcription again so that the realtime transcriber can start listening to what we're saying next at the end of all this we're just simply initializing the AI voice agent class that we created so we're going to initialize that so that we can actually start this process and then we start start off by starting transcription so that's where the loop starts and then now you can actually hit run and start demoing it I'm traveling to Paris next week what are some things that I should see okay so the user is planning a trip to Paris and wants to know what to see H I need to provide a good list of mustsee attractions without being too long first off Paris has iconic landmarks like the Eiffel Tower and the Lou Museum those are pretty much must visits for anyone there then there's Versailles with its Grand Gardens if you found this tutorial helpful click like and comment in the description box below your thoughts or any improvements that you have and to check out more videos like this click on this video right here

Original Description

๐Ÿ”‘ Get your AssemblyAI API key here: https://www.assemblyai.com/?utm_source=youtube&utm_medium=referral&utm_campaign=yt_smit_28 Github repo: https://github.com/smithakolan/DeepSeek-R1-AI-Voice-Agent AssemblyAI Streaming docs: https://www.assemblyai.com/docs/getting-started/transcribe-streaming-audio?utm_source=youtube&utm_medium=referral&utm_campaign=yt_smit_28 ๐Ÿ’ฌ Build a Real-Time AI Voice Agent with DeepSeek R1 & ElevenLabs! ๐ŸŽ™๏ธ๐Ÿš€ In this video, Iโ€™ll show you how to create a real-time AI voice agent using DeepSeek R1 (7B model), AssemblyAI for speech-to-text, and ElevenLabs for text-to-speech. This setup allows for seamless AI conversations, where the voice agent listens, thinks, and responds in natural-sounding speech! ๐Ÿ”น What Youโ€™ll Learn: โœ… How to transcribe speech in real-time using AssemblyAI โœ… How to use DeepSeek R1 via Ollama for AI-generated responses โœ… How to convert text responses into realistic AI voices with ElevenLabs โœ… How to build a low-latency AI voice assistant for real-time interactions Timestamps: 00:00 - Intro 01:00 - Demo 01:49 - Installing AssemblyAI, Ollama for DeepSeek R1 and Elevenlabs 03:38 - Building the AI voice agent in python 12:35 - Demo โ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌ CONNECT โ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌ ๐Ÿ–ฅ๏ธ Website: https://www.assemblyai.com ๐Ÿฆ Twitter: https://twitter.com/AssemblyAI ๐Ÿฆพ Discord: https://discord.gg/Cd8MyVJAXd โ–ถ๏ธ Subscribe: https://www.youtube.com/c/AssemblyAI?sub_confirmation=1 ๐Ÿ”ฅ We're hiring! Check our open roles: https://www.assemblyai.com/careers โ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌโ–ฌ #MachineLearning #DeepLearning
Watch on YouTube โ†— (saves to browser)
Sign in to unlock AI tutor explanation ยท โšก30

Playlist

Uploads from AssemblyAI ยท AssemblyAI ยท 0 of 60

โ† Previous Next โ†’
1 Python Speech Recognition in 5 Minutes
Python Speech Recognition in 5 Minutes
AssemblyAI
2 Python Click Part 1 of 4
Python Click Part 1 of 4
AssemblyAI
3 Python Click Part 2 of 4
Python Click Part 2 of 4
AssemblyAI
4 Python Click Part 3 of 4
Python Click Part 3 of 4
AssemblyAI
5 Python Click Part 4 of 4
Python Click Part 4 of 4
AssemblyAI
6 Deep learning in 5 minutes | What is deep learning?
Deep learning in 5 minutes | What is deep learning?
AssemblyAI
7 How to make a web app that transcribes YouTube videos with Streamlit | Part 1
How to make a web app that transcribes YouTube videos with Streamlit | Part 1
AssemblyAI
8 How to make a web app that transcribes YouTube videos with Streamlit | Part 2
How to make a web app that transcribes YouTube videos with Streamlit | Part 2
AssemblyAI
9 Batch normalization | What it is and how to implement it
Batch normalization | What it is and how to implement it
AssemblyAI
10 Real-time Speech Recognition in 15 minutes with AssemblyAI
Real-time Speech Recognition in 15 minutes with AssemblyAI
AssemblyAI
11 Regularization in a Neural Network | Dealing with overfitting
Regularization in a Neural Network | Dealing with overfitting
AssemblyAI
12 Add speech recognition to your Streamlit apps in 5 minutes
Add speech recognition to your Streamlit apps in 5 minutes
AssemblyAI
13 Transformers for beginners | What are they and how do they work
Transformers for beginners | What are they and how do they work
AssemblyAI
14 Automatic Chapter Detection With AssemblyAI | Python Tutorial
Automatic Chapter Detection With AssemblyAI | Python Tutorial
AssemblyAI
15 Deep Learning Series Part 1 - What is Deep Learning?
Deep Learning Series Part 1 - What is Deep Learning?
AssemblyAI
16 Deep Learning Series part 2 - Why is it called โ€œDeep Learningโ€?
Deep Learning Series part 2 - Why is it called โ€œDeep Learningโ€?
AssemblyAI
17 Activation Functions In Neural Networks Explained | Deep Learning Tutorial
Activation Functions In Neural Networks Explained | Deep Learning Tutorial
AssemblyAI
18 Deep Learning Series part 3 - Deep Learning vs. Machine Learning
Deep Learning Series part 3 - Deep Learning vs. Machine Learning
AssemblyAI
19 Deep Learning Series part 4 - Why is Deep Learning better for NLP?
Deep Learning Series part 4 - Why is Deep Learning better for NLP?
AssemblyAI
20 Intro to Batch Normalization Part 1
Intro to Batch Normalization Part 1
AssemblyAI
21 Intro to Batch Normalization Part 2
Intro to Batch Normalization Part 2
AssemblyAI
22 Intro to Batch Normalization Part 3 - What is Normalization?
Intro to Batch Normalization Part 3 - What is Normalization?
AssemblyAI
23 Intro to Batch Normalization Part 4
Intro to Batch Normalization Part 4
AssemblyAI
24 Intro to Batch Normalization Part 5
Intro to Batch Normalization Part 5
AssemblyAI
25 Sentiment Analysis for Earnings Calls with AssemblyAI
Sentiment Analysis for Earnings Calls with AssemblyAI
AssemblyAI
26 Summarizing my favorite podcasts with Python
Summarizing my favorite podcasts with Python
AssemblyAI
27 Introduction to Regularization
Introduction to Regularization
AssemblyAI
28 How/Why Regularization in Neural Networks?
How/Why Regularization in Neural Networks?
AssemblyAI
29 Getting Started With Torchaudio | PyTorch Tutorial
Getting Started With Torchaudio | PyTorch Tutorial
AssemblyAI
30 Types of Regularization
Types of Regularization
AssemblyAI
31 Tuning Alpha in L1 and L2 Regularization
Tuning Alpha in L1 and L2 Regularization
AssemblyAI
32 Dropout Regularization
Dropout Regularization
AssemblyAI
33 What is GPT-3 and how does it work? | A Quick Review
What is GPT-3 and how does it work? | A Quick Review
AssemblyAI
34 Backpropagation For Neural Networks Explained | Deep Learning Tutorial
Backpropagation For Neural Networks Explained | Deep Learning Tutorial
AssemblyAI
35 Jupyter Notebooks Tutorial | How to use them & tips and tricks!
Jupyter Notebooks Tutorial | How to use them & tips and tricks!
AssemblyAI
36 Best Free Speech-To-Text APIs and Open Source Libraries
Best Free Speech-To-Text APIs and Open Source Libraries
AssemblyAI
37 Regularization - Early stopping
Regularization - Early stopping
AssemblyAI
38 Regularization - Data Augmentation
Regularization - Data Augmentation
AssemblyAI
39 Bias and Variance for Machine Learning | Deep Learning
Bias and Variance for Machine Learning | Deep Learning
AssemblyAI
40 Recurrent Neural Networks (RNNs) Explained - Deep Learning
Recurrent Neural Networks (RNNs) Explained - Deep Learning
AssemblyAI
41 What is BERT and how does it work? | A Quick Review
What is BERT and how does it work? | A Quick Review
AssemblyAI
42 Introduction to Transformers
Introduction to Transformers
AssemblyAI
43 Transformers | What is attention?
Transformers | What is attention?
AssemblyAI
44 Transformers | how attention relates to Transformers
Transformers | how attention relates to Transformers
AssemblyAI
45 Transformers | Basics of Transformers
Transformers | Basics of Transformers
AssemblyAI
46 Supervised Machine Learning Explained For Beginners
Supervised Machine Learning Explained For Beginners
AssemblyAI
47 Transformers | Basics of Transformers Encoders
Transformers | Basics of Transformers Encoders
AssemblyAI
48 Transformers | Basics of Transformers I/O
Transformers | Basics of Transformers I/O
AssemblyAI
49 How to evaluate ML models | Evaluation metrics for machine learning
How to evaluate ML models | Evaluation metrics for machine learning
AssemblyAI
50 Unsupervised Machine Learning Explained For Beginners
Unsupervised Machine Learning Explained For Beginners
AssemblyAI
51 Weight Initialization for Deep Feedforward Neural Networks
Weight Initialization for Deep Feedforward Neural Networks
AssemblyAI
52 Q-Learning Explained - Reinforcement Learning Tutorial
Q-Learning Explained - Reinforcement Learning Tutorial
AssemblyAI
53 Should You Use PyTorch or TensorFlow in 2022?
Should You Use PyTorch or TensorFlow in 2022?
AssemblyAI
54 What is Layer Normalization? | Deep Learning Fundamentals
What is Layer Normalization? | Deep Learning Fundamentals
AssemblyAI
55 I created a Python App to study FASTER
I created a Python App to study FASTER
AssemblyAI
56 How to create your FIRST NEURAL NETWORK with TensorFlow!
How to create your FIRST NEURAL NETWORK with TensorFlow!
AssemblyAI
57 Neural Networks Summary: All hyperparameters
Neural Networks Summary: All hyperparameters
AssemblyAI
58 Getting Started with OpenAI API and GPT-3 | Beginner Python Tutorial
Getting Started with OpenAI API and GPT-3 | Beginner Python Tutorial
AssemblyAI
59 Convert Speech-To-Text In Python in 60 seconds!
Convert Speech-To-Text In Python in 60 seconds!
AssemblyAI
60 Gradient Clipping for Neural Networks | Deep Learning Fundamentals
Gradient Clipping for Neural Networks | Deep Learning Fundamentals
AssemblyAI

This video teaches how to build an AI voice agent using DeepSeek R1 model with AssemblyAI API, AMA, and 11 Labs for real-time speech to text and text to speech functionality. The project utilizes Python and various libraries such as PortAudio for audio streaming. By following this tutorial, viewers can learn how to create a real-time transcriber object, generate AI responses, and convert responses to audio streams.

Key Takeaways
  1. Sign up for Assembly AI API key
  2. Download AMA
  3. Install PortAudio
  4. Install Assembly AI library
  5. Install AMA library
  6. Define a real-time transcriber object
  7. Set parameters for real-time transcriber
  8. Connect transcriber and create microphone stream
  9. Define methods for real-time transcriber
  10. Generate AI response using DeepSeek R1 model
๐Ÿ’ก The DeepSeek R1 model can be used for AI response generation, and the Assembly AI API can be utilized for real-time speech to text functionality, allowing for the creation of a comprehensive AI voice agent.
๐Ÿ”’ Pro feature: Ask AI to explain this lesson โ†’

Related Reads

๐Ÿ“ฐ
Is AI Quietly Killing the Open Web?
Learn how AI search compares to traditional search engines and its potential impact on the open web
Medium ยท LLM
๐Ÿ“ฐ
Will Developers Need LLM Integration Skills in 2026 for Success?
Developers will need LLM integration skills in 2026 to stay competitive, learn how to integrate AI into your workflow
Dev.to AI
๐Ÿ“ฐ
I Trained a 471M-Parameter Language Model From Scratch on One RTX 4090 in 100 Hours.
Train a large language model from scratch on a single GPU in under 100 hours, leveraging recent advances in AI hardware and software
Medium ยท LLM
๐Ÿ“ฐ
Masking PII Without Losing It
Learn to mask personally identifiable information (PII) without losing its value using LLMs, ensuring user privacy and data security
Medium ยท LLM

Chapters (5)

Intro
1:00 Demo
1:49 Installing AssemblyAI, Ollama for DeepSeek R1 and Elevenlabs
3:38 Building the AI voice agent in python
12:35 Demo
Up next
5 Levels of AI Agents - From Simple LLM Calls to Multi-Agent Systems
Dave Ebbelaar (LLM Eng)
Watch โ†’