{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com\n",
      "Collecting pydub\n",
      "  Downloading pydub-0.25.1-py2.py3-none-any.whl.metadata (1.4 kB)\n",
      "Downloading pydub-0.25.1-py2.py3-none-any.whl (32 kB)\n",
      "Installing collected packages: pydub\n",
      "Successfully installed pydub-0.25.1\n"
     ]
    }
   ],
   "source": [
    "# !pip install groq\n",
    "# !pip install pydub "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Audio Processing Pipeline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from groq import Groq\n",
    "import os\n",
    "import re\n",
    "import shutil\n",
    "import numpy as np\n",
    "from pydub import AudioSegment\n",
    "from langchain_core.documents  import Document"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "client = Groq(api_key = os.getenv('GROQ_API_KEY'))\n",
    "model = 'whisper-large-v3'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Audio to Text\n",
    "def audio_to_text(filepath):\n",
    "    with open(filepath, \"rb\") as file:\n",
    "        translation = client.audio.translations.create(\n",
    "            file=(filepath, file.read()),\n",
    "            model=\"whisper-large-v3\",\n",
    "        )\n",
    "    return translation.text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "# testing the function\n",
    "path = \"data/3.0.m4a\"\n",
    "transcript = audio_to_text(path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Alright, so now it's time to talk about the model training part. So I used the same code for the three of them. Alright, so I'm not going to go through one of them, okay? So here's what happened. Remember, after we flimmed the files for each of the datasets, they were all saved with a unique name. Right? So immediately when you get to the training phase, the dataset was loaded. The clean dataset for the corresponding data was loaded right then there was only four practically no need for some extra processing but if there's a need probably to convert from numerical to categorical as expected all right so then the next thing was to select because at every point in time you are selecting an attack as zeroed in so the thing is that we are going to um actually i'm going to select a part of the normal case as a as an addition to the zero day okay so let's say for example we're working with analysis right i'm working on analysis so i'm going to say that okay uh if analysis initially add let's say 200 000 rows in the data set all right i'm going to select corresponding 200 000 rows in the data set for the normal case so that makes it for my zero d attack i have 200 000 normal keys and also seven thousand notes sorry and also 200 000 attack case which is the zero d and in this case analysis so the other ones that were not selected from the first one that is the other the remaining normal ones from the 600k rows right they will be used in training the in the model right while the remaining attacks all right will be used as a target variable to train the model so what happens is that you have to split our data into the train set and zero ticked set so definitely this train set is going to have its own test set from its own self right but we initially want to like separate this data so that you know you know that we have a different data for train sets you also have a different data for what for for testing the zero attacks in this case I pick one of the attack as zero D all right so then we go on to do that to proceed with zero D normal with yeah I just described I just described how that went right so in this case we have analysis and letting turn red key as as my as my 0d normal right then I'm using all of the other attacks excluding sorry and I'm using only 0d only the analysis attack as my 0d attack all right so so on that key normal and analysis as my zero day attack okay all right then um so the many ones are used right the meaning no more are used for training why do you mean your tax I use for training so that we can only have analysis as our zero day as expected here right Alright, so the next thing to do here is to transform our data right? We use standard scalar to process data to ensure that our data is much more distributed Alright, so that's what we do, we use standard scalar So we scale on the train set and we infer on the zero day set Alright, so the train set is itself split in two now you should notice that the train sets okay we only have two categories in the train sets you only have the normal attack because we know this are the we are assuming that the other attacks are attacks so we are categories we are categorizing them as just a single attack so we have normal and attack and in the zero day data so we have the normal and the attack each with two unique um two unique um target variables which is either normal attack okay so We created a metric which is called the calculateZDR metric. So this metric is responsible to calculate the 0D rates. So I can share the code to that if you need it. So then after we've processed our data, we've trained a machine learning model which is random forest um classifier model on the attack now this first training here is to dust off the data set in view all right so we trained with the model with the thought of wanting to get the top features so automatically after training the model you perform feature importance to extract the top 30 features all right 30 features special top 10 features for the UNSW data center shot it up 30 features but for the CI CDS we're starting the top 40 features because it has more attacks than the like it has more more more features rather okay and this one so we're dealing with okay so we train the machine learning model after the model is done training we infer immediately right we infer immediately to get the top 30 features then we now train a new machine learning model again so that's gonna give us a model that is much more robust in the sense right to only some to only the top important features we don need the lesser ones all right so then apparently the model kind of like you know it performed well in some cases in some other cases like for attacks like fuzza attacks the model didn't perform so well right that is the machine learning model so the next one wants to create a deep learning model all right so in this case we are using pytosh as our as our programming language or selected as our deep learning framework all right then we have uh we have five forwards so looking at talking about the layout of this model right we have um we have five layers we have five layers which is the patch normal yeah so this is the mlp the multi-layer uh perception model okay built with pythons so we did python rather so we have five layers and for each layer there's a dropout it's a 50 dropout all right so then that's for the data that's for the model for the python so this model apparently appears to be one of the best model we have so far because when it comes to zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero zero rate detection it's performed very well right so the other one that we worked with is the cnn module and this model is also similar to that model it also has five layers but now it has um it has a patch normalization layer and also a dropout layer added to it so we are using the convolutional 1d layer right then immediately after each of the layer we have the patch normalization 1d layer and also the dropout layer so that's for the models and lastly we have the voting classifier to combine these models together and depending on the kind of aggregating voting method that was used in this case we used soft all right to ensure that uh we are not too strict on coming up with a final uh a final approach all right so that's all that's all this is a bit longer already that's all\n"
     ]
    }
   ],
   "source": [
    "print(transcript)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def split_audio_by_duration(audio_file_path, chunk_duration_minutes, print_output=True):\n",
    "    # Convert chunk duration to milliseconds\n",
    "    chunk_length_ms = chunk_duration_minutes * 60 * 1000\n",
    "\n",
    "    # Load audio file\n",
    "    audio = AudioSegment.from_file(audio_file_path)\n",
    "    audio_duration_ms = len(audio)\n",
    "\n",
    "    # Create a temporary directory for storing chunks\n",
    "    base_filename = os.path.basename(audio_file_path).split('.')[0]\n",
    "    chunk_folder = f\"{base_filename}_chunks\"\n",
    "    if not os.path.exists(chunk_folder):\n",
    "        os.makedirs(chunk_folder)\n",
    "\n",
    "    chunk_paths = []\n",
    "\n",
    "    if audio_duration_ms > chunk_length_ms:\n",
    "        # Calculate the number of chunks\n",
    "        num_chunks = audio_duration_ms // chunk_length_ms + (1 if audio_duration_ms % chunk_length_ms != 0 else 0)\n",
    "\n",
    "        for i in range(num_chunks):\n",
    "            start_ms = i * chunk_length_ms\n",
    "            end_ms = min(start_ms + chunk_length_ms, audio_duration_ms)\n",
    "            chunk = audio[start_ms:end_ms]\n",
    "            chunk_filename = f\"{chunk_folder}/{base_filename}_chunk{i+1}.mp3\"\n",
    "            chunk.export(chunk_filename, format=\"mp3\")\n",
    "            chunk_paths.append(chunk_filename)\n",
    "            if print_output:\n",
    "                print(f'Exporting {chunk_filename}')\n",
    "    else:\n",
    "        # If audio duration is less than the chunk duration, store the whole file as a single chunk\n",
    "        chunk_filename = f\"{chunk_folder}/{base_filename}_chunk1.mp3\"\n",
    "        audio.export(chunk_filename, format=\"mp3\")\n",
    "        chunk_paths.append(chunk_filename)\n",
    "        if print_output:\n",
    "            print(f'Exporting {chunk_filename}')\n",
    "\n",
    "    return chunk_folder, chunk_paths\n",
    "\n",
    "def transcribe_audio_chunks(audio_file_path, chunk_duration_minutes):\n",
    "    # Split the audio file into chunks\n",
    "    chunk_folder, chunk_paths = split_audio_by_duration(audio_file_path, chunk_duration_minutes)\n",
    "\n",
    "    documents = []\n",
    "    for chunk_path in chunk_paths:\n",
    "        # Transcribe the chunk\n",
    "        transcript = audio_to_text(chunk_path)  # Assuming this function exists\n",
    "\n",
    "        # Extract the base filename and chunk index using regex\n",
    "        chunk_filename = os.path.basename(chunk_path)\n",
    "        match = re.search(r'(.*)_chunk(\\d+)\\.mp3$', chunk_filename)\n",
    "        if match:\n",
    "            base_filename = match.group(1)\n",
    "            chunk_index = int(match.group(2))\n",
    "        else:\n",
    "            # Default values in case of unexpected filename format\n",
    "            base_filename = os.path.splitext(chunk_filename)[0]\n",
    "            chunk_index = 1  # Assuming it's the first chunk\n",
    "\n",
    "        # Calculate the chunk's start and end times in minutes\n",
    "        start_min = (chunk_index - 1) * chunk_duration_minutes\n",
    "        end_min = chunk_index * chunk_duration_minutes\n",
    "        actual_end_min = min(end_min, (len(AudioSegment.from_file(audio_file_path)) // 60000))  # To handle the last chunk's actual duration\n",
    "\n",
    "        # Create a document with the transcript and metadata\n",
    "        metadata = {\n",
    "                \"filename\": base_filename,\n",
    "                \"duration\": f\"{start_min}-{end_min} minutes\"\n",
    "            }\n",
    "        document = Document(page_content=transcript, metadata=metadata)\n",
    "        documents.append(document)\n",
    "\n",
    "    # Delete the chunk folder after processing\n",
    "    shutil.rmtree(chunk_folder)\n",
    "\n",
    "    return documents\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Exporting audio-2_chunks/audio-2_chunk1.mp3\n",
      "Exporting audio-2_chunks/audio-2_chunk2.mp3\n",
      "Exporting audio-2_chunks/audio-2_chunk3.mp3\n",
      "Exporting audio-2_chunks/audio-2_chunk4.mp3\n",
      "Exporting audio-2_chunks/audio-2_chunk5.mp3\n",
      "Exporting audio-2_chunks/audio-2_chunk6.mp3\n",
      "Exporting audio-2_chunks/audio-2_chunk7.mp3\n"
     ]
    }
   ],
   "source": [
    "# Example usage\n",
    "audio_file_path = \"data/audio-2.mp3\"  # Replace with your audio file path\n",
    "chunk_duration_minutes = 3  # Replace with your desired chunk duration in minutes\n",
    "documents = transcribe_audio_chunks(audio_file_path, chunk_duration_minutes)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Document metadata: {'filename': 'audio-2', 'duration': '0-3 minutes'}\n",
      "Transcript:  Hey guys, ChrisFix here and today I'm going to show you how to change the oil in your car or truck. This video is specifically geared to beginners who have never done an oil change. So this is going to be an in-depth video and after watching it you'll be able to change your own oil. Many inexpensive oil change shops will use cheap oil and really cheap filters. So by doing an oil change yourself you could use good motor oil, a good filter, and know the job is getting done right. Plus you get to save some money and it's fun to work on your own car. If you've ever done oil changes before and want to share your tips, leave a comment. Now let's take a look at the tools you need to change your oil. So here's everything you're going to need to change your oil. You can see we're just using common hand tools. We have a socket set that has a ratchet and some sockets. Gloves so you don't get the oil on your skin because oil is not good for you. Paper towels to clean up. We have our oil and filter and I'll explain in a second how to find the correct oil and the correct filter for your car. We have an oil filter wrench, you might need it or you might not but it's worth to have just in case. We have an oil catch pan so you can recycle your old oil and a funnel so you can fill up your engine with new oil. I'm also including a breaker bar just in case your drain bolt is hard to get off. This will make it really easy. In addition to tools to change the oil, you're also going to need something to jack your vehicle up. In this case we have ramps or you could use jack and jack stands and then a piece of wood to block off the rear tires and I'll show you everything. There's also another method you could use where you don need any of this You could just drive your vehicle up onto the curb to get enough access to safely get underneath and drain the oil So you can use whatever method works for you I just want to note also that any tools that I using here including the jacks jack stands ramps and even the oil check the description. I'll link everything. So if you don't have something, you could easily find it and you could easily see what I used. And as always, if you have any questions throughout this process, leave a comment below and I answer every question and comment. So by the end of this video, you'll be an oil change expert. So let's go take a trip to the store and let me show you how to find out what oil your car takes. To figure out what oil your car takes, you can look in the owner's manual. So just go grab your owner's manual. We're going to flip to the back here. You can look under oil and capacities. You can see it tells you how much oil you're going to need. So we're going to need 4 1⁄4 quarts. And then you want to check the viscosity of the oil that you need. and we're going to need 4 1⁄4 quarts of 0W-20. So let's go to the store and we'll check that out right now. Alright, we're in the store and we need to find a synthetic 0W-20 oil. There's a ton of oil to choose from. Here is 0W-20. You can see, here's where the viscosities are listed. 0W-20 is right here. Here's 10W-30. So make sure you get the correct viscosity. Here's the 0W-20 we need. We want a full synthetic. We need at least 4 quarts and this container has 5, so that's plenty. If you have an older car, you might not need synthetic, but I personally like running synthetic oil even in my older cars. There are a lot of myths out there on switching to synthetic, and just to be clear, I don't think there's a lot of myths out there on switching to synthetic. I think it's a good idea to switch to synthetic oil. I think it's a good idea to switch to synthetic oil.\n",
      "Document metadata: {'filename': 'audio-2', 'duration': '3-6 minutes'}\n",
      "Transcript:  so that you know you could switch to synthetic and you could switch back to conventional at any time. Conventional is cheaper, but on most new cars, you need to run synthetic. Plus, synthetic oil lasts longer. Speaking of how long oil lasts, change your oil at the recommended mileage that's listed in the owner's manual. Many cars have an oil life monitor that'll tell you when you need to change your oil, so just go by that. If you can't find any information on when you need to change your oil, I change the oil in my cars at around 5,000 miles. My van has over 300,000 miles, and we've had that car since new, and she's still running great. Okay, so we have our oil. Now let's go find the filter. There are tons of oil filters, but which one do you pick? Well, just look in the book here, and we're doing the oil change on a 2014 Nissan Sentra. Personally, I like using pyrolator filters, but any quality filter will do. We need an L14612. Okay, L14612, L14612, right here. Good. So there we go. We got the oil and the filter. I'm going to go check out real quick, and let's go change the oil. All right, so now that we got our correct viscosity oil, 0W20, and we have the correct oil filter, let's get underneath this car. And I'm going to show you how to jack the car up first, and then I'm going to use the because that what I prefer So an oil change has three basic parts One you got to drain the oil Two you have to change the oil filter And three you have to fill it with the correct new oil Let go step by step so you know exactly what you need to do The first step is to drain the oil. And to get to the oil drain plug, we have to go underneath the vehicle. So we're going to have to lift the vehicle up. To jack the car up, if you're not completely sure how to do it, you could check the owner's manual. It tells you exactly how to jack the car up to change a spare tire. But I'm going to show you right here what you need to do. And you want to make sure before where you jack the vehicle up, you block off the rear tire so the car doesn't roll. The other thing you want to do is if you have an automatic, make sure it's in park. If you have a manual, put it in first gear and also pull the emergency brake which will prevent the car from rolling. So get your jack and place it underneath the vehicle right where your jacking points are. In this case, the jacking points have these little indents in them. That area of the frame is meant to support the vehicle and then you can jack the car up. Once the car is jacked up you can get your jack stands and place it under the car right where there's a big piece of metal on the frame and then you're going to lower the car down onto the jack stands and then you have plenty of room to get to the oil pan. So we'll just let the car down slowly and you can see the jack stand is the only thing holding it up and once your car is safely supported on the jack stands I always like I like to put the jack right back on the frame just for extra support. So if for some reason the jack stand slips or something or malfunctions, you have backup with the jack.\n",
      "Document metadata: {'filename': 'audio-2', 'duration': '6-9 minutes'}\n",
      "Transcript:  Never be too safe. So that's how you jack your car up to do an oil change. I want to show you the method that I prefer. It's a lot easier, a lot safer, and that's using ramps. Make sure you always use jack stands and not just the jack. You don't want to just rely on the jack to protect you from the car falling on you. Like you saw, I like to use both. Double the protection. Now using ramps is my favorite method. It's the easiest, it's the safest, and it also raises the vehicle pretty high. All you have to do is park the vehicle in a spot where you can slide two ramps right under the wheels and then you just drive the car up the ramps. It's that simple. Make sure that you pull the emergency brake again and we're blocking off the rear tires again. And I think you can get why I like the ramps so much. Before you go under the car, even when you have the car jacked up, what you want to do is you want to just shake the car with your hand. The car should not move anywhere. You're just shaking it back and forth as hard as you can and it should be stable and this thing is stable. Once you know that the vehicle is safe to go under, you can see why I like using the ramps. Look at all this room that we have now. Alright so now let's go under the car and find the oil drain plug. So you can see my feet over there. This is the front of the car right here. And then we're looking up here. And if we look here you can see there's a bunch of stuff and you might be confused, oh where's the bolt that I need to undo? Where's the oil drain bolt? Well what you want to do is you want to locate the drain pan The drain pan is this right here It usually black and has a bolt coming out You can see the bolt right back here That your oil drain pan Now there's other things that look like it, but this should be pretty easy to find because you're looking for that bolt and you're looking for the black pan. But you could also see right here is another drain pan. But this drain pan here doesn't have any bolts to let fluid out. This is the transmission drain pan. So really simple to find the oil drain pan. And then actually you can see right behind the drain pan you want to locate your oil filter. In this case, oil drain pan here, oil filter is right behind it and it's up and down nice and easy to get to which is really good. In some vehicles, the oil filter is actually on top of the engine. For example, in this Toyota Tacoma you can see here. In this case though, it's underneath, it's pretty easy to get to. This is really easy to get to also. You can see the drain plug right there. Let's go get it off. Now before we remove the drain plug, get your oil collection pan, slide it under. Now we have a sideways view, you can see our filters right here, our oil drain pan is right here and our oil drain plug is right there. We have our oil catch can right here, it's kind of aimed behind a little bit because the oil is going to come out that way. In this case we're using a 14mm socket on our ratchet and to loosen you want to go this way counterclockwise righty-tighty lefty-loosey. So this might be a problem some of you might encounter where you're using your normal size ratchet it's hard to get\n",
      "Document metadata: {'filename': 'audio-2', 'duration': '9-12 minutes'}\n",
      "Transcript:  That drain plug out. Well don't be discouraged. There's an easy trick to use. And that trick is to use one of these long breaker bars. You can see here how much longer it is than my ratchet. And this is going to give you so much leverage that it's going to be really easy to get off. If you don't have a long breaker bar like this, you can get your ratchet and slip a pipe over the end to make it longer. Watch how easy this is going to be now. Boom, it's loosened. That's all it took. all it took. So now we can loosen this the rest of the way. Once it gets really loose, make sure your drain pan is ready to go. And you can loosen this by hand. Now you can wait for all the oil to drain out. Now I should mention, some people say you should change your oil after you run the car for like 10 minutes so the oil is warm and it flows easier. In reality, it doesn't matter. If you want to change your oil with the car sitting there, you just jack it up and the car is cold, all that oil is going to be in the oil pan. You're not going to risk burning yourself, and sometimes it just makes the job easier. Now if you're going to put your car up on the ramps, then you're starting your car anyway. Just make sure if you run your engine, you let it sit for like five to 10 minutes. Let it cool off a little bit so you don't burn yourself, and also so all the oil collects in the drain pan. On some oil drain plugs, there's a gasket to help seal the plug, and you can see here there's a copper crush gasket. These gaskets are generally one use so take off the old gasket and replace it with a new one Some people reuse these gaskets one or two times and never have a problem with leaks and I one of those people but in general I suggest you replace the gasket. Alright, the oil is completely drained. There are a few drops coming out, so let's screw in the drain plug and move on to the next step. Just screw it in by hand and it should tighten right up. I like to wipe away any extra oil before I tighten it down all the way so your drain pan stays clean and so you know if there's any oil leaking from the drain plug down the road. Now we want to tighten up our drain plug and to do that we want to go clockwise. So we're going to switch this so now we're going to tighten this clockwise and notice I'm using our ratchet and not our breaker bar. You want to use the small ratchet to tighten this. You're only tightening it so it's snug you don't want to over tighten it. You over tighten it you'll strip the drain plug and you'll cause way more problems. You have a washer on there. All you need to do is tighten it down to 20 foot pounds of torque, which is nothing. So use the small ratchet. Tighten it, and once it's snug, give it a little extra turn. And that's it. So we just finished step one, removing all the old oil. Now step two is changing the old oil filter. Okay, so we should be be able to get this off by hand. Nope, too tight. So if your oil filter is tight and it won't come off, we have four different style tools that you can use to get your oil filter off. This one's my favorite because it works for all different sizes.\n",
      "Document metadata: {'filename': 'audio-2', 'duration': '12-15 minutes'}\n",
      "Transcript:  It's literally just a wrench and it grabs on and then you can turn it. This one, put it in here and then as you turn, you can see it gets smaller. But you can see this is a really small filter. This is for actually a big 454 cubic inch engine. So the oil filter on that is huge. Here's another adjustable one. It's rubber so it grabs on really tight. Just close it by pulling the rubber through here. and then when you turn to loosen, you turn like this, and it kind of grips because it's turning on here and grabbing it. These are good because they're adjustable, and they work on all different sizes. And the last style is this style, but you need it for each specific size that you use. But this is a really small filter, so you can see it won't work. But the idea is it's just like a giant socket for a filter. And then you can put your wrench right in here, just like that, and then boom. comes right off. But we're going to be using this because it's easy to use, quick, grabs on all different size filters. So let's get this filter off. Okay. You can see that does the trick. We can unscrew this the rest the way by hand. Make sure your oil catch can is right below where this is because this is going to leak oil. As you can see There we go Just put that right in there Alright so with our old filter out we want to grab our new filter And I like to pre-oil my filter. It prevents the car from running dry when you first start it up. So if you just put this filter in now and screw it in, there's no oil in here. So the oil has to fill this and then go to all the engine parts. But if we fill this first with our brand new oil, then we don't have to worry about the engine running dry and this is just going to give you a longer lasting engine. I should also mention that not every car you're going to be able to pre-fill these because some cars it's upside down or some cars it's in sideways. We just want to carefully fill this filter to the top just like that. Now what you want to do is you want to get oil around this gasket. You can see a little bit of oil got on the gasket just by chance but you want to make Make sure you have a clean finger. Just get a little bit of oil and just put it right around this gasket. And what that's going to do is it's going to make it easier to come off next time you do this and it's also going to prevent leaks. And that's all you need to do. Now let's go install it. So there's the drain pin. We go up and you look here and that's what the oil filter adapter looks like. And if we look there you can see the oil filter screws right onto that middle stud there. So it screws in right there. And you just try to make it flush as you turn it. So if it's flat as you turn it, it's going to be a little bit more stable.\n",
      "Document metadata: {'filename': 'audio-2', 'duration': '15-18 minutes'}\n",
      "Transcript:  should grab and you'll know when it grabs you'll feel it. Don't force it, it should go on really easily. You can see there, it's on. So now I just tighten it by hand. Don't use any tools to tighten these, just tighten it by hand. If your hands are slippery because it's oily, you grab a towel, clean it off and then turn it more by hand with the towel. Good. So step one is done. Step two, changing the oil filter is done. Now let's get the car on the ground and do step three which is adding new oil. So we're going to add the oil to the engine while we're on the ramps just so that we make sure that we don't start the engine with no oil in it. And when you're looking for where you add your oil, it's usually at the top of the engine. Here's where you check your oil. You can see it says engine oil on here. And that's not where you fill it. Where you fill it is right up here. It has the oil sign. It's upside down but it has the oil sign on here. And this is all dirty so you don't want to just take this cap off you want to clean the area first because you don't want that junk falling into the engine so just get your paper towel get in here and clean it good now that that's clean we can take this cap off and we'll place our funnel right in here so we could fill the engine up with brand new oil so on the side of our bottle we have a scale here that tells you how many quarts or liters you have and you want to do this on a level surface but you can see we pretty much full right now and we need to add four quarts It was four and a quarter quarts with the filter but we added the oil to the filter so it really just four quarts So we want to have a quart left which is right down here. I always have a towel ready just in case. I hate spilling oil on engine parts. Just a little top tip. If you pour it sideways like this, you actually have a little more control, surprisingly. And usually the oil doesn't come out in blobs. It comes out nice and smooth instead. So if we look here we have about a half a quart we need to add. And it looks like we're at about one quart so I'm going to stop there. Close that up. So we just finished the last step which is add oil. We have one more step to do and And that is to get the car off the jack stands, or in this case the ramp, on level ground and check the oil. Since we added oil, we can start the car. And you just want to make sure that there's no oil lights on. And you can see the oil light isn't on, so that means the engine's getting oil. Now we can back the car down. And now that we have the car back down on level ground, let's go check the oil. So shut the engine off. You want to let the engine sit for about 5 minutes so all the oil drops back down since we did start the engine.\n",
      "Document metadata: {'filename': 'audio-2', 'duration': '18-21 minutes'}\n",
      "Transcript:  After you let it sit for five minutes, get a towel, pull your dipstick out and clean it off. Put it back in. Make sure it's pushed down all the way. And then pull the dipstick back out. Okay, if we look at the dipstick, what you're looking for is the oil. You can see the oil's over here. There's low and there's high. So that dot right there means that the oil is low and you need to fill it up. That dot right there means the oil is high and it means that you have it completely full. Anywhere in between is good. I prefer trying to get it to the high. Now sometimes it's hard to see how much oil is on here, especially this brand new oil and especially this synthetic oil. So if you flip this over, you actually get a better look and you can see the oil goes right there. So we're right on the high, which is perfect. So we don't have to add oil or anything. If yours is too low, add a little bit of oil and check the level again. If you end up adding a little bit too much oil, that's not a big deal. If you add over a quart of extra oil, then you have a problem and you probably have to remove some of it because that could actually cause engine problems And that is the complete guide to changing oil in your car or truck Hopefully after this video you have no questions but if you do have questions just comment below I answer every comment and question Also if you end up doing your first oil change after watching this video, definitely let me know because I love to hear that stuff. Hopefully this video was helpful. If it was, remember to give it a thumbs up. Up on the screen are going to be other videos. You can find the links to those videos as well as any links to any tools that I used in this video in the description. The top tip for this video is, well, where do I put all my oil that I drained out from my filter and from the car? And the answer to that is you want to dispose all of your oil responsibly. You can see here in the corner of my garage I have all these old oil containers. I really need to make an oil run. But what you do is you just fill up a container. It could be an old oil container, it could be a milk container, orange juice, whatever you have. And what you do is you just fill up these containers and you go to your local auto parts store, your local garage, your local recycle center, places that sell the oil like Walmart, most of those places will take the oil and they'll take it for free so that they could recycle it so it doesn't become an environmental hazard.\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# Output the documents for verification\n",
    "for doc in documents:\n",
    "    print(f\"Document metadata: {doc.metadata}\")\n",
    "    print(f\"Transcript: {doc.page_content}\") "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['filename', 'duration'])"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "doc.metadata.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'filename': 'audio-1', 'duration': '3-6 minutes'}"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "documents[1].metadata"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "# creating a function to create audio document\n",
    "def create_audio_document(audio_file_path, chunk_duration_minutes=3):\n",
    "    documents = transcribe_audio_chunks(audio_file_path, chunk_duration_minutes)\n",
    "    return documents"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Exporting audio-1_chunks/audio-1_chunk1.mp3\n",
      "Exporting audio-1_chunks/audio-1_chunk2.mp3\n",
      "Exporting audio-1_chunks/audio-1_chunk3.mp3\n",
      "Exporting audio-1_chunks/audio-1_chunk4.mp3\n",
      "Exporting audio-1_chunks/audio-1_chunk5.mp3\n",
      "Exporting audio-1_chunks/audio-1_chunk6.mp3\n",
      "Exporting audio-1_chunks/audio-1_chunk7.mp3\n"
     ]
    }
   ],
   "source": [
    "# testing the function\n",
    "audio_file_path = \"data/audio-1.mp3\"\n",
    "documents = create_audio_document(audio_file_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Document(metadata={'filename': 'audio-1', 'duration': '0-3 minutes'}, page_content=\" Hello friend, how is it going? Welcome back to Toyota Maintenance YouTube channel. I have today in my shop this 2009 Toyota Corolla LE. She has only 90,000 miles on the odometer. I don't know this vehicle at all. It's a new customer, new car and they asked for a very detailed inspection. The inspection is successfully finished and that gives me great opportunity to talk about the most common problems with this generation of Corolla. And let's go and start with the problem which will be most expensive to repair. And I'm pointing at this car for the reason the name of it is written right here. Variable valve timing. This 1.8 liter 2Z RFE engine is equipped with the variable valve timing and if you will have a problem with it you will basically hear the rattling on the cold start. It is the known problem but I even hesitate if I should say it very common problem I personally didn see that much happening on the cars I serviced in the past And of course it always very important when you have an engine with VVT to be on top of the oil changes keeping the oil clean and possibly avoid these problems. Speaking about engine oil, we have immediately another common problem. These engines are known for engine oil consumption. Unfortunately, some of them were using or eating engine oil way faster, consuming the oil way faster than they supposed to. to. So this vehicle has a windshield sticker for 5,000 miles. All change there is still remaining 900 miles and let me show you what I discovered on my inspection. I let it sit so the oil got a chance to get all the way in the oil pan. I pulled that engine oil lipstick and of course it was confirmed it's barely touching the low mark I hope you can see it on it yeah so even this engine is consuming more than it's supposed to within a 5,000 miles\"),\n",
       " Document(metadata={'filename': 'audio-1', 'duration': '3-6 minutes'}, page_content=\" It was correctly filled to the top. This is way too much. Between the marks on this engine I believe it's 1.4 quarts. So this is way too much and this engine is part of that problem. Is it catastrophic problem or something what should stop you from purchasing it? Well, that's up to debate. It will not stop me buying this vehicle. All I will have to do within 2,000 miles or 3,000 miles is check the oil. And here it's so easy to add another 1 quart of the oil. Also, 1 quart of the oil, even if you buy the full synthetic 0W-20, costs only like 7 bucks. So what's the big deal? And let's be organized and continue still or stick still with the engine oil. And we will be looking on this side passenger side of the engine. Some people will observe the oil engine oil on this side of the engine. Do you see that sensor which is coming out there? It could be leaking from that. Or we can look a little bit later when we will lift this vehicle up we can look on the back of the engine where is timing chain tensioner it a hydraulic tensioner and its gasket could be leaking surprisingly and i agree with that it on most of these i see those leaks surprisingly this one is absolutely dry i already looked from underneath this one is exception to the rule if we stay together on this side and I will bring that light for one last time right underneath the alternator hopefully you see the water pump pulley so the water pumps they don't last forever is it the common problem I will not say I will say it's common maintenance but the word common is there so these water pumps are right here driven by this belt nicely on outside it's not a timing belt moving it because this engine has timing chain so this is a relatively easy repair a little note also what do you see right here this doesn't have an automatic belt tensioner but it's manual basically through this alternator. It's right here in front of you. Maybe that light was actually not helping us. You see the tensioner? Right here. The next item is related to the ignition.\"),\n",
       " Document(metadata={'filename': 'audio-1', 'duration': '6-9 minutes'}, page_content=\" 100% say that these engines to ZRFs they have it's a common that they are misfires detected you will get that check engine light and then P0 whatever codes for misfire on the multiple cylinders or on the one only and so on and so on this vehicle the owner who brought it first time here wrote it in the comment or told me in the text message he said yeah that is there is a history with misfires on this engines on this engine particle engine and there is already one or multiple coils installed as a part of that detail inspection I confirmed that I can see that number two might be Toyota but it's not matching the way it's dirty so it was replaced I believe these are Terta Danzos yes made in Japan now what will shock you somebody was taking care of that misfire they replaced the coil and to my amazement well I was not amazed about this they did obviously replace the spar plugs To my amazement they put completely wrong spark plugs in it 2009 2ZRFE 1 liter engine and I will be not discussing in this video whatsoever that 2 liter it different beast So we focus on most common engine and the most common problems in these Corollas. So somebody put in it NGK. This engine is supposed to have only Denso SC20HR11. Did I say it correctly? SC20HR11. It's already coming. I sent the report, detailed report to the owner. I said no, that doesn't belong there. It is nice and new, but it doesn't belong there. There's supposed to be only iridium acetyl-HR11. What I pulled out, newly looking, NGK, ILKAR7B11 non-iridium plug. Why is it there? Well, because somebody was in a hurry, They then maybe had no access to the SC20HR11, but most likely they wanted safe money. This is way cheaper than Iridium's power plug which goes up to 16 bucks a piece. This one maybe was 8. Eight dollars stands for somebody made 32 dollars. Like that, just cutting corners. So no way, the owner already said.\"),\n",
       " Document(metadata={'filename': 'audio-1', 'duration': '9-12 minutes'}, page_content=\" We will put the correct spark plugs. I ordered them. They are on the way. Meanwhile we are making this video. And these misfires were correctly repaired by replacing the coils. It actually the service who did this work fixed the problem. They replaced the coil which was failing. So I agree with them. That's fine. just for God's sake if you can please put correct spark plugs in that engine so the owner will not have problems in the future I already inspect the remaining areas as you know me throttle body is dirty the muff it's dirty engine air filter it's on the dirty side we are going to replace it brake fluid which cannot see it's opening from here brake fluid is also dirty the battery is incorrect it's supposed to be bigger you can even see it doesn't fit in that holder i even tested it state of health it's only like 70 percent so that should be replaced too but this i'm just giving you walk around let's go back to the most common problems. Here this vehicle still have a automatic transmission dipstick If you will stick with the advice which is written on it which says no need to replace the ATF blah blah blah blah blah well don do it maintain your fluid in your transmission don't listen to those crazy stickers they were putting on these at those years that's all nonsense we know we need to change the engine oil and maintain that and we need we know that when the automatic transmission fluid is burned it's contaminated it also needs to be replaced but these automatic transmissions are not part of this video as the common problems it's exactly opposite I don't remember at the dealer and here in my mini shop I don't remember ever have one failed I'm not saying they don't but it's not a common what is common they last actually for the lifetime of the vehicle just give them nice and clean oil another common problem we will discuss right here and it actually will be two of them right in middle of your screen. Number one front wheel bearing\"),\n",
       " Document(metadata={'filename': 'audio-1', 'duration': '12-15 minutes'}, page_content=\" This vehicle has only 90,000 miles but guess what? Both bearings are already showing very small play. This one I don't know why but as usually this one is smaller. It starts on this side and the other ones follow. Let me show you. Hopefully you will be able to hear it. That's a lift. There is definitely, I will say like a millimeter if I can say that, on that diameter here the movement. So it's already in the comments and we will be dealing with that problem soon. That's unfortunately pretty costly if you have to replace bows from wheel bearings. And I said there will be two items right in front of you in the middle of screen. Wheel bearing right here and the struts. Struts, I don't know why, are relatively common problem on these. Not the rear ones. The rear has also struts. I never replaced one of them ever you can see it right here nicely it's a very simple design here nothing really go bad here except we will be coming back there but for different item So the struts on both sides these ones are totally fine Now how you will see your struts are bad Well the vehicle will start kind of bouncing around but mainly even if it's on the ground You will see there will be oil even the towers below here. It will be all wrapped in the oil. When that goes it starts leaking pretty crazy and everything will be wet here. So these ones are still original OEM and they are still holding pretty good. Where we were together looking on that engine bay you didn't see any power steering reservoir also we were looking on that water pump and the belt and the belt was kind of simply going around that's because this vehicle was equipped or is equipped with electric steering apparently there were some failures on it and it was to certain degree common problem there was campaign or it was being taken care of I personally don't see it so I'm hesitating if it should be included in the common problems I don't\"),\n",
       " Document(metadata={'filename': 'audio-1', 'duration': '15-18 minutes'}, page_content=\" have these problems coming to me so I will say no but I wanted make you aware that there were definitely in certain years with that electric steering there were problems with it. Last but not least unfortunately you will discover problem and it's a common problem and you will discover it in the vehicle on your dashboard. It's not this problem. This is some kind of incredible improvement by the owner. This doesn't count. So you will be driving your vehicle and suddenly you will get that check engine light on. You will have a code for EVEB and you will hope it's just a loose filler cap or the ratchet is broken on that filler cap. You will hope it's the code and in this case it will be code for a very small leak. But unfortunately these are pretty common for filling right here. I said we will be coming back here. This is that entire evap canister. It's a complicated unit and it's very expensive. So if you ever have evap codes which are saying the purge flow is incorrect or something like that pay for a correct diagnosis because these from dealer can be extremely pricey So what is my conclusion for 2009 to 2013 Corolla generation? What's conclusion? Will I buy one or will I say no? Way too problematic vehicle. I think with the correct maintenance and paying at least a little bit of attention to the engine and keeping that oil lever correctly, I think these are super great vehicles to drive from point A to point AB. Nothing exciting obviously, but they are gas savers, they are reliable and I will say in relativity of automotive world they are super cheap to maintain in my opinion the brake job everything it's easy you have a rear drum brakes in the back you can drive a lot of miles on those this one has brand new brake pads almost in front might be the first replacement at 90 000 miles The rear brake shoes I already opened that are still 2-3mm might be purely theoretically original too.\"),\n",
       " Document(metadata={'filename': 'audio-1', 'duration': '18-21 minutes'}, page_content=\" this without any hesitation buy one of these to just get to the work and back and save a lot of money on the gas that's my feeling you please share underneath the video your experience with others because that's why we filming this creating community of Toyota enthusiasts who share their own own experience if you like the video give it a thumb up and be subscribed i will always have a lot of new stuff coming your way thank you for watching and have a great day my friend\")]"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "documents"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "smog_env",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
