Skip to content

Commit

Permalink
Fix circular import
Browse files Browse the repository at this point in the history
  • Loading branch information
sultur committed Aug 30, 2023
1 parent e4a4d76 commit 47f6792
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
6 changes: 4 additions & 2 deletions src/icespeak/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
"""

from .parser import GreynirSSMLParser
from .transcribe import DefaultTranscriber, TranscriptionOptions, fast_transcribe, gssml
from .parser import GreynirSSMLParser, fast_transcribe
from .settings import SETTINGS
from .transcribe import DefaultTranscriber, TranscriptionOptions, gssml
from .tts import AVAILABLE_VOICES, text_to_speech

__all__ = (
Expand All @@ -31,4 +32,5 @@
"AVAILABLE_VOICES",
"TranscriptionOptions",
"fast_transcribe",
"SETTINGS",
)
20 changes: 19 additions & 1 deletion src/icespeak/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,30 @@
from logging import getLogger

from .settings import SETTINGS
from .transcribe import GSSML_TAG, DefaultTranscriber, TranscriptionMethod
from .transcribe import (
GSSML_TAG,
DefaultTranscriber,
TranscriptionMethod,
TranscriptionOptions,
)
from .tts import AVAILABLE_VOICES

_LOG = getLogger(__file__)


def fast_transcribe(
text: str,
voice: str = SETTINGS.DEFAULT_VOICE,
options: TranscriptionOptions | None = None,
):
"""
Simple wrapper for token-based transcription
of text for a specific TTS voice.
"""
t = AVAILABLE_VOICES[voice]["Transcriber"] or DefaultTranscriber
return t.token_transcribe(text, options)


class GreynirSSMLParser(HTMLParser):
"""
Parses voice strings containing <greynir> tags and
Expand Down
16 changes: 0 additions & 16 deletions src/icespeak/transcribe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
PunctuationTuple,
)

from icespeak.settings import SETTINGS
from icespeak.tts import AVAILABLE_VOICES

from .num import (
ROMAN_NUMERALS,
CaseType,
Expand Down Expand Up @@ -1512,16 +1509,3 @@ def token_transcribe(
token.txt = cls.entity(token.txt)

return detokenize(tokens)


def fast_transcribe(
text: str,
voice: str = SETTINGS.DEFAULT_VOICE,
options: TranscriptionOptions | None = None,
):
"""
Simple wrapper for token-based transcription
of text for a specific TTS voice.
"""
t = AVAILABLE_VOICES[voice]["Transcriber"] or DefaultTranscriber
return t.token_transcribe(text, options)

0 comments on commit 47f6792

Please sign in to comment.