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

Format Python code with pipx run ruff format #358

Merged
merged 1 commit into from
Nov 3, 2024
Merged
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
51 changes: 25 additions & 26 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,33 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc']
extensions = ["sphinx.ext.autodoc"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'pyttsx3'
copyright = '2017, Natesh M Bhat'
author = 'Natesh M Bhat'
project = "pyttsx3"
copyright = "2017, Natesh M Bhat"
author = "Natesh M Bhat"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '2.6'
version = "2.6"
# The full version, including alpha/beta/rc tags.
release = '2.6'
release = "2.6"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -69,10 +69,10 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -83,7 +83,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = "alabaster"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -94,13 +94,13 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'pyttsx3doc'
htmlhelp_basename = "pyttsx3doc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -109,15 +109,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -127,19 +124,15 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'pyttsx3.tex', 'pyttsx3 Documentation',
'Natesh M Bhat', 'manual'),
(master_doc, "pyttsx3.tex", "pyttsx3 Documentation", "Natesh M Bhat", "manual"),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'pyttsx3', 'pyttsx3 Documentation',
[author], 1)
]
man_pages = [(master_doc, "pyttsx3", "pyttsx3 Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
Expand All @@ -148,7 +141,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'pyttsx3', 'pyttsx3 Documentation',
author, 'pyttsx3', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"pyttsx3",
"pyttsx3 Documentation",
author,
"pyttsx3",
"One line description of project.",
"Miscellaneous",
),
]
26 changes: 14 additions & 12 deletions example/repeatvoice.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import pyttsx3 # pyttsx3 is a text-to-speech conversion library in Python
import speech_recognition as s #Google Speech API in Python
import pyttsx3 # pyttsx3 is a text-to-speech conversion library in Python
import speech_recognition as s # Google Speech API in Python

# Functional programming Model

#Functional programming Model

def text_to_speech(text):
#engine connects us to hardware in this case
eng= pyttsx3.init()
#Engine created
# engine connects us to hardware in this case
eng = pyttsx3.init()
# Engine created
eng.say(text)
#Runs for small duration of time otherwise we may not be able to hear
# Runs for small duration of time otherwise we may not be able to hear
eng.runAndWait()


def speech_to_text():
r=s.Recognizer()# an object r which recognises the voice
r = s.Recognizer() # an object r which recognises the voice
with s.Microphone() as source:
#when using with statement. The with statement itself ensures proper acquisition and release of resources
# when using with statement. The with statement itself ensures proper acquisition and release of resources
print(r.recognize_google(audio))
text_to_speech(r.recognize_google(audio))

text_to_speech(r.recognize_google(audio))


speech_to_text()
7 changes: 3 additions & 4 deletions pyttsx3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

_activeEngines = weakref.WeakValueDictionary()


def init(driverName=None, debug=False):
'''
"""
Constructs a new TTS engine instance or reuses the existing instance for
the driver name.

Expand All @@ -15,7 +16,7 @@ def init(driverName=None, debug=False):
@type debug: bool
@return: Engine instance
@rtype: L{engine.Engine}
'''
"""
try:
eng = _activeEngines[driverName]
except KeyError:
Expand All @@ -28,5 +29,3 @@ def speak(text):
engine = init()
engine.say(text)
engine.runAndWait()


Loading