Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added voice feedback feature using pyttsx3, which is an offline text-to-speech library. #13351

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import sys
from pathlib import Path

import pyttsx3
import torch

FILE = Path(__file__).resolve()
Expand Down Expand Up @@ -310,6 +311,15 @@ def write_to_csv(image_name, prediction, confidence):
# 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)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Usage: pip install -r requirements.txt

# Base ------------------------------------------------------------------------
pyttsx3
gitpython>=3.1.30
matplotlib>=3.3
numpy>=1.23.5
Expand Down
Loading