Skip to content

Commit 47f6792

Browse files
committed
Fix circular import
1 parent e4a4d76 commit 47f6792

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

src/icespeak/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
2020
"""
2121

22-
from .parser import GreynirSSMLParser
23-
from .transcribe import DefaultTranscriber, TranscriptionOptions, fast_transcribe, gssml
22+
from .parser import GreynirSSMLParser, fast_transcribe
23+
from .settings import SETTINGS
24+
from .transcribe import DefaultTranscriber, TranscriptionOptions, gssml
2425
from .tts import AVAILABLE_VOICES, text_to_speech
2526

2627
__all__ = (
@@ -31,4 +32,5 @@
3132
"AVAILABLE_VOICES",
3233
"TranscriptionOptions",
3334
"fast_transcribe",
35+
"SETTINGS",
3436
)

src/icespeak/parser.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,30 @@
2828
from logging import getLogger
2929

3030
from .settings import SETTINGS
31-
from .transcribe import GSSML_TAG, DefaultTranscriber, TranscriptionMethod
31+
from .transcribe import (
32+
GSSML_TAG,
33+
DefaultTranscriber,
34+
TranscriptionMethod,
35+
TranscriptionOptions,
36+
)
3237
from .tts import AVAILABLE_VOICES
3338

3439
_LOG = getLogger(__file__)
3540

3641

42+
def fast_transcribe(
43+
text: str,
44+
voice: str = SETTINGS.DEFAULT_VOICE,
45+
options: TranscriptionOptions | None = None,
46+
):
47+
"""
48+
Simple wrapper for token-based transcription
49+
of text for a specific TTS voice.
50+
"""
51+
t = AVAILABLE_VOICES[voice]["Transcriber"] or DefaultTranscriber
52+
return t.token_transcribe(text, options)
53+
54+
3755
class GreynirSSMLParser(HTMLParser):
3856
"""
3957
Parses voice strings containing <greynir> tags and

src/icespeak/transcribe/__init__.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@
4545
PunctuationTuple,
4646
)
4747

48-
from icespeak.settings import SETTINGS
49-
from icespeak.tts import AVAILABLE_VOICES
50-
5148
from .num import (
5249
ROMAN_NUMERALS,
5350
CaseType,
@@ -1512,16 +1509,3 @@ def token_transcribe(
15121509
token.txt = cls.entity(token.txt)
15131510

15141511
return detokenize(tokens)
1515-
1516-
1517-
def fast_transcribe(
1518-
text: str,
1519-
voice: str = SETTINGS.DEFAULT_VOICE,
1520-
options: TranscriptionOptions | None = None,
1521-
):
1522-
"""
1523-
Simple wrapper for token-based transcription
1524-
of text for a specific TTS voice.
1525-
"""
1526-
t = AVAILABLE_VOICES[voice]["Transcriber"] or DefaultTranscriber
1527-
return t.token_transcribe(text, options)

0 commit comments

Comments
 (0)