Added voice feedback feature using pyttsx3
parent
6629839d5f
commit
9af02c565f
10
detect.py
10
detect.py
|
@ -34,6 +34,7 @@ import os
|
|||
import platform
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import pyttsx3
|
||||
|
||||
import torch
|
||||
|
||||
|
@ -310,6 +311,15 @@ def run(
|
|||
# Print time (inference-only)
|
||||
LOGGER.info(f"{s}{'' if len(det) else '(no detections), '}{dt[1].dt * 1E3:.1f}ms")
|
||||
|
||||
if s.startswith("0"):
|
||||
engine = pyttsx3.init()
|
||||
engine.say(f"{s.split (':') [1][8:]}") # Convert label to speech
|
||||
engine.runAndWait()
|
||||
else :
|
||||
engine = pyttsx3.init()
|
||||
engine.say(f"{s.split (':') [2][8:]}")
|
||||
engine.runAndWait()
|
||||
|
||||
# Print results
|
||||
t = tuple(x.t / seen * 1e3 for x in dt) # speeds per image
|
||||
LOGGER.info(f"Speed: %.1fms pre-process, %.1fms inference, %.1fms NMS per image at shape {(1, 3, *imgsz)}" % t)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# Usage: pip install -r requirements.txt
|
||||
|
||||
# Base ------------------------------------------------------------------------
|
||||
pyttsx3
|
||||
gitpython>=3.1.30
|
||||
matplotlib>=3.3
|
||||
numpy>=1.23.5
|
||||
|
|
Loading…
Reference in New Issue