Dataset Viewer
Auto-converted to Parquet Duplicate
audio
audioduration (s)
4.24
30
transcription
stringlengths
89
608
I'm going to show you how to do professional quality voice cloning. That's where you train a model to be able to read out text in a voice that sounds just like you. I'm going to show you how to prepare data. You'll need about three hours of a recording, hopefully high quality of your voice. I'll show you how to prepare...
I'll show you how the quality compares to commercial models out there, specifically the best models from 11 labs. Now, it goes without saying that these types of models are now widely available. And that means voice cloning is very good, which is great. But of course, it means people can clone your voice. And it's some...
So I'm going to explain, well, I'll show you some quick examples first, just so you're convinced on quality. But then I'll explain briefly how these models work. There is a previous video where I explain this a lot more, so I'll move fairly fast. Then I'll describe how to create the high quality data set. Then I'll go ...
These are probably two of the strongest open source models out there now. There's also a model called Dia that's quite good, but it's not supported by transformers or RunSloth yet. Probably it's a little bit better than Orpheus. I think Orpheus on paper is a little bit better than CSM1B from Sesame. But we'll see how t...
You'll be able to find all the scripts for today over on trellis.com forward slash advanced transcription. This contains all scripts for voice cloning, but also for text-to-speech, speech-to-text and speech-to-speech models. This is a paid repo, but there are a lot of free resources available on Onsloth. If you want to...
And then add in some of the tricks I'll cover today in this video. So let's compare the quality of a few different voices. And I recommend maybe don't look at the screen for a moment and just listen to these recordings and think about which one is real and which one is transcribed. So I'm going to play four different s...
And from there, you can start to think about which parts of my pipeline are weak and why and what can I do to improve those parts of the pipeline. Here's the second. And from there, you can start to think about which parts of my pipeline are weak and why and what can I do to improve those parts of the pipeline. And her...
And from there, you can start to think about which parts of my pipeline are weak and why and what can I do to improve those parts of the pipeline. And from there, you can start to think. All right. So I've played four snippets.
The first one was 11 Labs, their highest quality model, which I trained called Pro Voice Cloning on three hours of my voice. The second one was the real recording that I recorded of myself. The third one was then a cloned audio from training the Sesame 1B model using full fine tuning. And the last one was a zero shot. ...
I did zero shot on CSM 1B, a fully fine tuned model again with three hours. So three of these were cloned. The very first one was from 11 Labs. The second one was the real one. And the two last ones were cloned as well. And you can see just how good the quality is. I think it would be very difficult for even me to tell...
The results, I think, are good. And probably you get similar or even better if you fully optimize Orpheus. But before I go into detail, let's go through a very little bit of theory so you can understand how these models work. I'm going to, yeah, just go through exactly what I told you. And, yeah, I suppose if you're ju...
Cleaning the audio of noise really helps. I'll show you how to do that. Levelizing the audio's volume really helps. So that, yeah, because actually I'm realizing some of my YouTube videos, I could do better levelizing the audio. It's a bit quiet in spots. But you want to kind of normalize it so it's around a baseline. ...
And if you want exceptional quality, I recommend fine tuning, but then also cloning. What's cloning? Cloning is where you feed in a piece of voice to the model. And it's able to use that as a reference for the next piece it generates. You can even try that on a model you didn't tune and it will get closer to your voice...
So that's what I'd recommend if you want the highest possible quality. All right, that's kind of the recipe. But we're going to follow the structure now, which is first briefly explaining these models, then talking about the data set, then fine tuning. I'll do CSM 1B first, then Orpheus. And then we look at evaluating ...
A language model like ChatGPT or GPT-40 takes in a sequence of tokens. Which are essentially words. And then it tries to predict the next word. And it does this recursively. So it will predict one, put it back as an input, then try to predict the next one. And so on here. And this is very analogous what we're doing wit...
So we would start off, we pass in some text that we want to convert to speech. We get out part of the speech. We pass it back. We get out parted speech. We pass it back. And so on. So at a high level, we're trying to do a token based approach. But we need this concept of an audio token. Now what's an audio token? How d...
And you assign a vector. You assign a vector to represent the speech within a certain time slot here. And actually, you define a vocabulary of these arrows. So rather than the arrow being able to continuously take any value, you define a dictionary or a code book that just allows it to take discrete values. And then yo...
Now, I know I'm giving abstract, but I'm giving high level. It's called a code book. And it's a set of fixed vectors in high dimensional space. It's not too deep. It's probably, you know, 512D or something larger. And you define a fixed number of arrows in that high dimensional space, maybe 4000. And then you've got to...
And here's how you come up with deciding which vectors, because, of course, the question is, well, how do I know which arrows I should consider to be in my code book? And the way you do that is you start with a sound wave. You put it through a neural net, often a transformer that will convert it into this dictionary. S...
And then you decode it out through another transformer different to this one here to get back to the input. So by running this over many sequences, many different sounds, you're going to be able to train an encoder and a decoder. So that you can get the sound represented as vectors and then get it back from vectors int...
Now, one of the problems with speech is it's got a lot more information than text. If you just read text, there's no emotion per se other than in the meaning of the words. Whereas with voice, I've got the timbre, I've got, you know, prosody, all these words, but volume even. So there's a lot more to represent within a ...
It turns out it's better for every window to try and represent it with a few tokens. Maybe you've got a coarse token that represents loosely some lower frequencies. Then you have a more granular token representing some kind of mid frequencies and a more granular one. So some kind of hierarchical approach, maybe, or at ...
They don't just use one token for every timestamp. They often use more than one. So actually, if you look across at CSM1B, it will decode a first token that's kind of coarse or that kind of describes the complete information in a window. And it actually uses a separate transformer to then decode or produce. I think it'...
You've got audio and text coming in. You've got a main token predicted. And then you're predicting more granularity here. And you go back then, pass in the main token here. And you do this recursively to decode out or generate all of the rest of your sequence. Now, Orpheus takes a little bit different of an approach. O...
It actually produces seven tokens in series for each timestamp. So it will say, okay, I'm at the timestamp of, let's say, two minutes here. I'm going to produce seven different tokens. But these seven I produce in a row are actually all referring to this two-minute timestamp. And then I'm going to take those seven and ...
So they use the same decoder to just autoregressively produce seven tokens for every timestamp. Then it will move to the next timestamp, produce seven. Then it will move to the next timestamp, timestamp, and produce seven. So, yeah, Orpheus, it uses a three billion parameter model. It's not shown here. Whereas Sesame u...
Or also because Sesame uses the secondary decoder, which is a lot smaller, it's able to decode one token and then very quickly decode the rest here. Whereas in Orpheus, it's a bit slower because the large model, the three billion, I mean, it's not that large. It's been used to decode every one of the seven tokens. So O...
Well, it's a simpler architecture. If you want to look at my style TTS2 video, which is a diffusion type approach, there are so many pieces in the architecture that need to be trained. It's very complex. You're trying to explicitly model things like emotion, like prosody, and you just have many parts in the network. Wh...
The nice thing is these tokens can kind of capture everything without explicitly having to dedicate part of the network to these things like emotion, noise, or music. And you can also cover multi-speaker or multi-instrument audio. This is kind of like what the Moshi model does. It will cover two tracks, one decoded tra...
So you can literally take a text model, which is kind of crazy, put it in here, and then you can tune it maybe on 100,000 hours. And you've got a model that seems to perform fairly well. So you can kind of get this big speed up by just leveraging a bootstrap of the models that are out there for text even. So this is pr...
I mentioned at the start of the video, it's possibly better than Orpheus, I read online, but it's not supported by Onslot or Transformers. If it's supported by Transformers, it will be supported by Onslot. So hopefully that will come out, but it's been in the GitHub issues for, I think, over a month. So with that, I kn...
So for all of this, I'll be working out of the advanced transcription repo. You can find more details on trellis.com. Probably I'll rename it soon to Advanced Audio, because it always has been covering not just transcription, but voice cloning and speech-to-speech, also diarization and turn detection. So I've cloned th...
And within this, you'll see there is a readme, which I've opened up. This one here. And am I in Onslot? Sorry, I want to be in the Onslot readme, which is this one here, actually. And let's put it in preview mode. And you can see a few things that we're going to cover today. The Onslot CSM fine-tuning. It's actually a ...
Both of these are based on Onslot notebooks, although the data preparation is something I developed, and I've changed quite a bit around the inference and some things around the fine-tuning. I'm not going to cover this in this video, but I am making a video soon on how to do inference on these models. The one that you ...
But it is possible now to use VLLM for this text-to-speech model, which I think is quite unique because I don't know of many libraries that support continuous batching for text-to-speech generation. So this is quite interesting, and I'm going to make a video on it soon. If you have access to the repo, you can read abou...
You can run it on RunPod if you want, or some other service, Vast.ai, or any other service that runs Jupyter Notebooks. But I'll just show it to you here in Google Collab. And we're going to work down top to bottom and see how this goes. So the first thing we need to do is prepare three hours of data. Where are we goin...
I'm going to take my YouTube videos, extract the audio from them, clean the audio, and then junk them. But you could take any recordings and upload them. I'll show you how to upload the files here. And then the third option is you could just record yourself on a microphone or something. Then you have sound files, and y...
And we'll install Whisper for doing transcription, sound file, and data sets. We'll also install YouTube YTDLP, which is for accessing YouTube videos. Now, one of the reasons I actually did this in Collab is because YouTube is not easily accessible if you try to do it from your local machine. But if you do it from Coll...
Then we're going to use Whisper in this notebook to transcribe the audio, which gives us text. Because to train a model, you need both text and you need the audio. Then we're going to clean the audio, and we're going to normalize the sound. And then we're going to chunk this into 30-second chunks. But we're going to re...
If you go to, let's see, Trellis, and I think I call something like, yeah, TTS Medium Clean. This is a three-hour data set. And there are going to be three columns. One is the audio, one is the text, and then one is the source. The source here just refers to the ID for the speaker. You could call it speaker ID maybe ei...
Notice how every piece of text ends with a full stop, because I've respected sentence boundaries in assembling this. And then you have the sound. If you're using large language models in production, you'll want a way to log. So yeah, the sound is quite clean because I've cleaned it. And you can see here, maximum length...
Arguably, it would be better to use 60-second data sets lengths. I haven't ablated it. I'm using 30 seconds right now. All right, so how do we get the YouTube videos? Well, first we're going to set our Whisper model choice. We'll use Turbo, which is almost as good as the large model in quality, but faster. We'll set th...
So I am connected here to an A100, which has got 40 gigabytes of VRAM. You can train it on the free T4 if you want. You go to change runtime type. I think you go to manage sessions. No, change runtime type. And you could select a T4. That should work as well. But yeah, it's going to be faster using the A100, and you ca...
Actually, it's cheaper if you run something like an A40 on RunPod, and it's faster if you run a H100 with 80 gigabytes or even an A100 with 80 gigabytes on RunPod. So I've set my device. I'm using the Turbo model. Here, if you want, you can upload some audio files. So for example, if you run this cell, it's just going ...
Well, I'm going to use YouTube. So I'll open this Download YouTube, and you can put in any number of URLs that you want. I'm just going to put in one URL here, and it's going to grab the audio, and it's going to then save that audio into my folder structure here. So what you should see is the YouTube DLP booting up, an...
So I've defined my audio directory as audio, and we have an error here. Let me see if I have properly installed everything. Okay, so yeah, I think it might just have been blocked because of IP address. So I have connected to my VPN, and I think this is working here now. So I should be downloading the YouTube video, and...
I'm just going to check if this is a very long YouTube. Similar flops. It's 33 minutes, so it's not too bad. Once that's downloaded, what we'll do is we will gather all of the files in the audio folder here, and we're going to just print out the length so we can see. Now, I've previously trained on six different files,...
Because I want to show you how to do the cleaning and normalization. This is going to take any audio file in the audio folder and put it into Audio Clean. And there's a few things we'll do to clean it. So we'll have a high-pass filter, which is going to remove low-frequency noise. We will use a denoiser here based on a...
And we're also going to add a tiny bit of silence at the end of each piece of audio, just to make sure that if any audio was kind of cut off just after a word, there's some extra sound that will help stabilize the training as well. So, yeah, we'll run this once. Well, I'll run it now, and it should run once the YouTube...
Because I want to see if the cleaned one is actually cleaner than the original. So we're going to run this here. And I'm not going to actually run it. I'm just going to play right away an original sound file from earlier. If you're using large language models in production, you'll want a way to log the prompts and the ...
It's quite quiet in the original audio here. My audio is quite clean because I think Descript cleans it when I record a YouTube video. So, yeah, that's probably why it's already quite good. But you can hear the effect of the volume normalization here. So once you're convinced that your cleaning is working fine, you can...
Now, the clean files will be very slightly longer because they have the added little 100 milliseconds of padding after each of the clips. So I'll rerun this here. And it should just show one of those files. Now, let's see how we're doing on the download. Looks like we're still downloading this file, so it could take a ...
You don't want to transcribe the original and then separately have a cleaned version because the lengths are going to be slightly different. So you want to keep with the cleaned one and use that all the way forward. So we load the whisper model here. And then we're going to save the transcript into a transcripts folder...
And we're going to transcribe the audio path that we pass in, which will be a path for each of the paths in cleaned paths. So basically, we're transcribing each of the scripts. So I'll run that. And this should give us then a transcripts folder. Once that's done, we're going to move to chunking. So at this point, we've...
And what we want to do is assemble all the words into one massive long string. And we're going to take that string for each video, by the way, and we're going to split it into sentences. And we're going to do that using YouTube or using NLTK. So there's an NLTK library that allows you to do that chunking. Now, you can ...
And now we can define the organization we're going to push to, which will be Trellis, and then the name of the model. And next up here, we're moving to that chunking that I described. So for the chunking, we're essentially going to combine all of the sentence, all of the words into one long sentence. And then we're goi...
And this allows us to detect sentence spans. So we're going to apply this to the full text. And the full text has been built up here just by essentially assembling all of the words into text. And when we apply it to the full text, it will return sentences. And then quite simply, we will start off trying to create our f...
And once we go over the 30-second, we'll actually drop that last one and just keep everything that brought us up to that 30. Now, it may be beneficial to train on 60-second snippets, so you could ablate that or even longer, 120. So at this point here, and I'll run this cell, what we should have is a set of sentences.
Sorry, a set of data set rows that have got combined sentences together and then the corresponding audio that's there for them. So we can print out a few of these. Actually, if you want, you can see a row here. The row's got audio, which is going to point to just a clip of audio that has been sized to match those sente...
So if you just want to see the text of one row, you can see right here, it's cleanly finishing on a full stop, which is what we want. So with that there, we're then going to push it up as a data set to a hugging face. Now, just in terms of assembling those columns, I just want to show you here. There are three columns....
And the source here, I'm just currently appending source 0 for speaker ID 0 to every single one of these rows. If you had alternating speakers, you'd need to append a different source to each of those. Just one other small note here. There's this thing where you can have hugging face show the data nicely, like with thi...
It will set a feature, a column feature for the data set on the audio column so that it recognizes it. And it will both show it nicely, but it will also allow you to do streaming when you're downloading. So you don't have to download the full file all at once during training. So, yeah, at this point, you should have pu...
Let's just quickly go back and take a look at some of the results. At this point, we have downloaded the YouTube video. So you can see that's done. We've gathered our files, of which there's only one. It's 33.74 minutes. We've cleaned it. And we have the cleaning is done. So all the clean files are in the audio clean f...
So actually right here, if we look at the original audio, you can see, yeah, it's actually not really added much on in that case there. It's pretty much the same length. And now we're transcribing. So we're running the whisper model. It's going to go through all of this here. And then it's going to save the transcript....
So we will install like this. Run this cell, which handles automatically if you're in Colab or not, because the install is a little bit different. And now we're going to load the model that we're going to train, which is the CSM1B model. And we will load it with the max sequence length of 2048. Now, actually, our longe...
But when we are doing some cloning later on, we will need to have this length. So actually, I recommend keeping it at this length. The data type is going to be brain float 16. If you're on an A100, automatically determined. If you're on a T4, it'll be float 16. You can train in 4-bit. I haven't tried it. And you can do...
And Laura is going to be quicker. So my notebook just moved there. And that's because the transcripts are done. So if I refresh here, I should see the transcripts appear momentarily unless it crashed. And yep, I see the transcript. And just to show you what that transcript looks like, it's got those word timestamps. So...
And you can see there's a timestamp for the start and the end in time of every single word. So yeah, this is how we've got a lot of detail. It allows us then to get the right length chunks. So as I said, we're going to not train with full fine tuning. We're going to download the model here. And first, yeah, we need to ...
And we're going to apply these small adapters. We will freeze the main weights and just train these little adapters. And at the very end, we will merge the little adapters back on. And this is a way to accelerate training, but also avoid overfitting in some cases. So if you want, you can print out what the model looks ...
We're going to use a rank of 32. We could maybe increase it for higher precision. For Laura alpha, you typically want for a small model, something like maybe 16. This scales the learning rate of the adapters because they are trained faster than the base model would be. Because when you operate in a lower dimensional sp...
And you'll know if you watch my other videos, I like using this kind of automatic learning rate scaling, which is called use rescaled Laura. It rescales the learning rate according to the square root of the rank, which is empirically the right scaling you want. So yeah, this here is going to get those adapters. It's ba...
Now we have our data ready. So we're going to load that from here. And we have our sampling rate, which is 24,000. That's required by the model. So we're now going to load up this data set. And for some of the processing of the model, we're going to need to have a processor, which we will load from unsloth. Basically, ...
If you look at one of the layers or all 15 of the layers look like this, they're going to have a tension. We're going to train. We're going to put adapters on the attention linear layers. We're going to put adapters on the MLP linear layers. And then for the depth decoder, you remember I said Sesame's got a main decode...
And then we have a much smaller model here. It's actually only got four layers. The smaller model does. And it's probably got a lot smaller characteristic dimensions. Actually, it doesn't really have that smaller dimensions. 1024 by 256. So, yeah, it's smaller. It's about half the size in terms of input features, for e...
And we're going to make sure that we have got a source defined. If the source isn't defined, it will just default it to zero. And now we're going to split it into an eval and train set. We're going to take a maximum of either 30 rows for eval or 10% of the data set. Now, I'm just looking at one video here. So there's n...
And once we've got the data set splits created, we'll print out the maximum length in tokens. Because this will tell us whether our model length was set to be sufficiently large. We need this to be below 2,000. And the max text length here, we'll see what that is. But it needs to be below 2,000 because that's what we l...
So I'm not loading just the video we processed because I'm loading the full data set. So I'm loading three hours worth of data here. That's why it's a little bit slower. And I know, therefore, the max length here is going to be 600. So we're going to be under the 2,000 needed. And now we're going to be able to get this...
So the nice thing about Sesame is it wraps all of the preparation within the processor chat template. So we just need to apply that chat template to the conversation, which contains the input text and the audio. And then we will tokenize it, return a dictionary, return output labels. And we do need to specify the argum...
And we are padding all these to be equal length. So you always, if you're putting in a batch bigger than one, you need your batch to all be the same length. Usually it's padded to the longest, but sometimes it might be padded to the max sequence length. And I think here, this should be padded to the maximum length of o...
The audio is much longer, but this is measured at a sampling rate of 24,000 hertz. So that's why it looks a lot longer. It's not the length of words. And we're going to pre-process the data set so that we get it in tensor format. So we're going to have input IDs. We're going to have a mask because it's autoregressive. ...
And then we're going to compare how good it is compared to our ground truth audio and calculated cross entropy loss based on that, which would be used for backprop. So here we have the data set, input IDs, attention mask labels that we do cross entropy on. And yeah, we also have these input values and cutoffs. I'm not ...
We won't call it full fine tuning because it's actually lower fine tuning. And then we'll put a time date stamp on it. And now we'll move to train. So for training, I know that we can fit a batch size of 16 in this 40 GB. We'll do effective batch size of 32 by accumulating the forward pass over two batches and then bas...
So the learning rate will ramp and then it will be constant at a value of actually 2E minus 4 because we're going to do LoRa. You need LoRa for full fine tuning. And we will report to TensorBoard. So we're going to be able to take a look at the training. And I am going to save the logs to this file here. Notice also th...
So out of the 40 GB, we've used up 11 GB already. The model is a 1B model. So it's actually kind of high. You would expect it to be only something like a few gigabytes. But I think it's fine. We'll run TensorBoard. And I could, let me see. I might just save this. It doesn't really matter because I've saved different on...
TensorBoard, it might take a second to load up. We're going to start the training in the meantime. Then we'll show the memory statistics at the end of training, which will include. Because right now only the model is loaded, but we're going to have to load, say, the optimizer states, the gradients. So we're going to us...
We're going to show logging steps every single step. And we're going to train for three epochs. So you can see we're just training on one GPU. Batch size is 16, but we're accumulating every two forward passes. So the effective batch size is 32. We're training the equivalent of 1.75% of the total model parameters, of wh...
And when that's done, we're going to run inference. So to run inference, we're going to take the model and we're going to run generate. It's actually quite simple because it's nicely wrapped in transformers and unsloth. We generate up to 125 new tokens, could generate more. We will pass in some text from an eval exampl...
So what do we do for cloning? Not only do we pass in text to read out, we also pass in a sample of the audio. So yeah, passing in a different sample, not the same one, but it's a sample of my voice from the eval set. And because this is passed in, the model tends to continue on from what this sound is like. That's call...
We can push the model up to hub. This will just push up the lower adapters. You can optionally merge the lower adapters onto the model and push it up to hub. And that kind of rounds out where we are. Now, let's just take a look at training for a second. We have moved to step five. So by now, I think we should see Tenso...
And if it doesn't load here, we'll just come back once we have that cell run. We may need to come back and rerun the cell. And in the meantime, I'm going to just play. Well, it's not even that interesting because I think I played these already. But these are samples of fine-tuned and real voice from earlier. But it's f...
And from there, you can start to think about which parts of my pipeline are weak and why.
But my YouTube does have some hesitation, which makes the most sense of the way. makes this voice a bit more realistic in some ways. So we should now be coming close to the first evaluation point because you evaluate every 20%. So that would be roughly every eight rows. So you can see here it's just doing evaluation on...
So here we go. We can take a look at the training. You want to keep an eye on the grad norm. It should be down towards one. It's a bit bouncy there, but it's kind of towards one. So I wouldn't be too displeased with that. At the learning rate, it's constant as we expect. And here's the training loss. It's, you know, fa...
Note that it's going to take about 10 minutes for us to run this training. So I'll probably just come back and we'll take a look at it a little bit later. I'll show you then what the LoRa sounds like as well. But what I'll do for now is I'm going to show you the Orpheus model, which is going to be the very same flow. B...
And I'm not going to run this. I'm just going to go down manually and explain what we see. Everything that I've talked about in the data generation is the same. It's just the fine tuning that's different. So taking this piece by piece, we have the unsloth model version of Orpheus that's been loaded. What's the differen...
I'm logged in anyway, and I've accepted the terms on these repos. So I could just use the official one. Everything here is the same. I find that with Orpheus, it's giving an error when I try to use full fine tuning. I haven't investigated a lot. So I've commented out for now. Print the model. It has the same names for ...
The data prep is going to be quite a bit different, actually. So with Orpheus, we're going to need to have a map between the ID and then the speaker name, because the convention for Orpheus is when you train the data. Let's say that you have some text you want to do into speech, like 1, 2, 3. The convention is if you t...
And if you had multiple speakers in your data set, you'd need to map the speaker ID onto that speaker name as well. Next, for data set prep, we're basically subbing in the ID of zero with the speaker's name. So that's what's happening here. And we're ensuring now we have three columns of modified data, which are still ...
Again, print out the length and maximum audio length. There's no difference there because I use the same data set. Split into train and eval. There's no difference there. But here things get a bit more crazy because you have to very manually do tokenization. There are essentially two tokenizers being used. One is for c...
So you download the SNAC model and then you use that in order to tokenize the audio. You can actually tokenize it on the GPU with CUDA if you want. Now, this here is rearranging the tokens because if you remember, the tokens have a hierarchical representation. You've this main token and then you kind of have two at a l...
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
3