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

fix/restore_dead_code #256

Merged
merged 1 commit into from
Sep 5, 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
39 changes: 37 additions & 2 deletions ovos_plugin_manager/templates/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pathlib import Path
from queue import Queue
from threading import Thread
from typing import AsyncIterable, List, Dict
from typing import AsyncIterable, List, Dict, Tuple, Optional

import quebra_frases
import requests
Expand All @@ -21,7 +21,6 @@
from ovos_utils import classproperty
from ovos_utils.fakebus import FakeBus
from ovos_utils.file_utils import get_cache_directory
from ovos_utils.file_utils import resolve_resource_file
from ovos_utils.lang.visimes import VISIMES
from ovos_utils.log import LOG, deprecated, log_deprecation
from ovos_utils.metrics import Stopwatch
Expand Down Expand Up @@ -132,6 +131,42 @@ def curate_caches(cls):
for cache in TTSContext._caches.values():
cache.curate()

###########
# deprecated methods
@deprecated("'get_message' has been deprecated without replacement", "1.0.0")
def get_message(self, kwargs) -> Optional[Message]:
msg = kwargs.get("message") or dig_for_message()
if msg and isinstance(msg, Message):
return msg

@deprecated("'self.get_lang' has been deprecated, access self.lang directly", "1.0.0")
def get_lang(self, kwargs) -> str:
return kwargs.get("lang") or self.lang

@deprecated("'self.get_gender' has been deprecated, access self.voice and self.lang directly", "1.0.0")
def get_gender(self, kwargs) -> Optional[str]:
gender = kwargs.get("gender")
message = self.get_message(kwargs)
if not gender and message:
gender = message.data.get("gender") or \
message.context.get("gender")
return gender

@deprecated("'self.get_voice' has been deprecated, access self.voice directly", "1.0.0")
def get_voice(self, kwargs):
voice = kwargs.get("voice")
message = self.get_message(kwargs)
if not voice and message:
# get voice from message object if possible
voice = message.data.get("voice") or \
message.context.get("voice")
return voice or self.voice

@deprecated("'self.get' has been deprecated, access self.voice and self.lang directly", "1.0.0")
def get(self, kwargs=None) -> Tuple[str, Optional[str]]:
kwargs = kwargs or {}
return self.get_lang(kwargs), self.get_voice(kwargs)


class TTS:
"""TTS abstract class to be implemented by all TTS engines.
Expand Down
6 changes: 4 additions & 2 deletions ovos_plugin_manager/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from typing import Optional

import pkg_resources
from ovos_utils.log import LOG
from ovos_utils.log import LOG, log_deprecation


class PluginTypes(str, Enum):
Expand Down Expand Up @@ -198,7 +198,9 @@ class ReadWriteStream:
with an optional maximum buffer size
"""

def __init__(self, s=b'', max_size=None):
def __init__(self, s=b'', chop_samples=-1, max_size=None):
if chop_samples != -1:
log_deprecation("'chop_samples' kwarg has been deprecated and will be ignored", "1.0.0")
self.buffer = deque(s)
self.write_event = Event()
self.lock = Lock()
Expand Down
25 changes: 4 additions & 21 deletions test/unittests/test_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from unittest.mock import patch, Mock

from ovos_bus_client.session import Session
from ovos_config import Configuration
from ovos_utils.fakebus import FakeBus, Message

from ovos_plugin_manager.templates.tts import TTS, TTSContext
Expand Down Expand Up @@ -119,24 +118,8 @@ def test_format_speak_tags_with_speech_no_tags(self):
tagged_with_exclusion = TTS.format_speak_tags("Don't<speak>Speak This.</speak>But Not this.", False)
self.assertEqual(tagged_with_exclusion, valid_output)

def test_playback_thread(self):
pass
# TODO

def test_tts_context(self):
pass
# TODO

def test_tts_validator(self):
pass
# TODO

def test_concat_tts(self):
pass
# TODO

def test_remote_tt(self):
pass
from ovos_plugin_manager.templates.tts import TTSValidator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused import: TTSValidator

The import from ovos_plugin_manager.templates.tts import TTSValidator is unused in the current context. This aligns with the static analysis tool's suggestion to remove it to clean up the codebase.

Apply this diff to remove the unused import:

- from ovos_plugin_manager.templates.tts import TTSValidator
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from ovos_plugin_manager.templates.tts import TTSValidator
Tools
Ruff

122-122: ovos_plugin_manager.templates.tts.TTSValidator imported but unused

Remove unused import: ovos_plugin_manager.templates.tts.TTSValidator

(F401)

# TODO


Expand Down Expand Up @@ -193,15 +176,15 @@ def test_get_tts_config(self, get_config):
self.CONFIG_SECTION, None)

def test_get_voice_id(self):
pass
from ovos_plugin_manager.tts import get_voice_id
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused import: get_voice_id

The import from ovos_plugin_manager.tts import get_voice_id is unused in the current context. This aligns with the static analysis tool's suggestion to remove it to clean up the codebase.

Apply this diff to remove the unused import:

- from ovos_plugin_manager.tts import get_voice_id
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from ovos_plugin_manager.tts import get_voice_id
Tools
Ruff

179-179: ovos_plugin_manager.tts.get_voice_id imported but unused

Remove unused import: ovos_plugin_manager.tts.get_voice_id

(F401)

# TODO

def test_scan_voices(self):
pass
from ovos_plugin_manager.tts import scan_voices
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused import: scan_voices

The import from ovos_plugin_manager.tts import scan_voices is unused in the current context. This aligns with the static analysis tool's suggestion to remove it to clean up the codebase.

Apply this diff to remove the unused import:

- from ovos_plugin_manager.tts import scan_voices
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from ovos_plugin_manager.tts import scan_voices
Tools
Ruff

183-183: ovos_plugin_manager.tts.scan_voices imported but unused

Remove unused import: ovos_plugin_manager.tts.scan_voices

(F401)

# TODO

def test_get_voices(self):
pass
from ovos_plugin_manager.tts import get_voices
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused import: get_voices

The import from ovos_plugin_manager.tts import get_voices is unused in the current context. This aligns with the static analysis tool's suggestion to remove it to clean up the codebase.

Apply this diff to remove the unused import:

- from ovos_plugin_manager.tts import get_voices
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
from ovos_plugin_manager.tts import get_voices
Tools
Ruff

187-187: ovos_plugin_manager.tts.get_voices imported but unused

Remove unused import: ovos_plugin_manager.tts.get_voices

(F401)

# TODO


Expand Down
Loading