YoloV9 Code for Object Detection + Segmentation and Tracking

Yolo V9 Tracking + Object Tracing + Segmentation

First, See The Video below then see the code to do Object Detection + Segmentation and Tracking in that

YoloV9 Code for Object Detection + Segmentation and Tracking

Now, See The Python Code for Video above

import numpy as np
import supervision as sv
from ultralytics import YOLO

model = YOLO("yolov9e-seg.pt")
tracker = sv.ByteTrack()
box_annotator = sv.MaskAnnotator()
label_annotator = sv.LabelAnnotator(text_color=sv.Color.BLACK)
trace_annotator = sv.TraceAnnotator()

def callback(frame: np.ndarray, _: int) -> np.ndarray:
    results = model(frame)[0]
    detections = sv.Detections.from_ultralytics(results)
    detections = tracker.update_with_detections(detections)

    labels = [
        f"#{tracker_id} {results.names[class_id]}"
        for class_id, tracker_id
        in zip(detections.class_id, detections.tracker_id)
    ]

    annotated_frame = box_annotator.annotate(
        frame.copy(), detections=detections)
    annotated_frame = label_annotator.annotate(
        annotated_frame, detections=detections, labels=labels)
    return trace_annotator.annotate(
        annotated_frame, detections=detections)

sv.process_video(
    source_path="1.mp4",
    target_path="1-result_2.mp4",
    callback=callback
)

Extract Voice from a Video and Save that in a file using Python (Speech Recognition)

Extract Voice from a Video and Save that in a file using Python (Speech Recognition)

In this video, We see how to extract speech text from video and save it in a file using Python. We use Python Packages and libraries that has trained by deep learning Speech Recognition models and has high accuracy. This is a Simple and Powerful code to Extract Speech from Video and do Speech Recognition on it.

Python Code of Video is :

import moviepy.editor as mp 
import speech_recognition as sr 

clip = mp.VideoFileClip("1.mp4")

clip.audio.write_audiofile("ExtractedAudio.wav")

r = sr.Recognizer()
audio = sr.AudioFile("ExtractedAudio.wav")

with audio as source:
    audio_file = r.record(source)

try :
    result = r.recognize_google(audio_data= audio_file)

    with open("result.txt", "w") as file :
        file.write(result)
        file.close()

    print("Runs Successfully")
    
except sr.UnknownValueError :
    print("Google Speech Recognition Engine Could not Understand Audio.")
except sr.RequestError as e:
    print("Could not Get response from Google, Error is {0}".format(e))
except Exception as e:
    print(e)

clip.close()
print("End")