Stop sign detection Development of visualization part part3 Notify by voice using socket communication when an object is detected

Until last time

Last time, I wrote up to the part to record using socket communication. This time, I would like to make the part to notify by voice after socket communication.

Functions implemented this time

When an object is detected on Yolov5 ➡ Socket communication is performed. ➡ Sound is played when socket communication is received.

Client side

detect.py


                    if label1=="chair":
                     print("Detected a chair.")
                     with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s2:
                         s2.connect(('127.0.0.1', 50007))
                         s2.sendall(b'isukenti')
                         data = s2.recv(1024)

server.py


from playsound import playsound
import socket

# AF =Means IPv4
# TCP/For IP, SOCK_Use STREAM
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    #Specify IP address and port
    s.bind(('127.0.0.1', 50007))
    #1 connection
    s.listen(1)
    #Wait until you connect
    while True:
        #When someone visits, enter the connection and address
        conn, addr = s.accept()
        with conn:
            while True:
                #Receive data
                data = conn.recv(1024)
                if not data:
                    break
                #print('data : {}, addr: {}'.format(data, addr))
                conn.sendall(b'Received: ' + data)
            playsound('2.wav')
                
                #Return data to client(b ->Must be byte)
                

Basically, I'm just playing the audio using playsound ().

I'm using this for voice creation. https://w.atwiki.jp/softalk/

To next time

Next time, I'd like to write a story with a little more content, but since I want to post the implementation as it is, it may end up as an article without content. I'm sorry. Next time, I would like to write a program that separates sounds for each object. Thank you.

Video that is actually moving

https://youtu.be/ua45mDZaiJM

Recommended Posts

Stop sign detection Development of visualization part part3 Notify by voice using socket communication when an object is detected
Stop sign detection Development of visualization part part2 Notify another system by socket communication when an object is detected
Stop sign detection Development of visualization part part4 When an object is detected, it is notified by voice using socket communication (multiple volumes)
Stop sign detection Development of visualization part part5 Display what was detected when an object was detected
Stop sign detection Development of visualization part part1 Detection and recording of objects * This time, the chair is detected (the model is not made by myself)