Skip to content

Commit

Permalink
Merge pull request #4 from mayankwebbing/mayank/dev
Browse files Browse the repository at this point in the history
HOTFIX: no attribute 'CACHE_DIR'
  • Loading branch information
drien authored Oct 3, 2024
2 parents 3049f9a + 34ae615 commit 567d518
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,22 @@ tts = JoinOp(
tts.process_to_file('output.mp3')
```

## Changelog

#### v1.0.2 (2024-10-03)

- Fixed crash when running with caching disabled (#3)

## Contributing

Contributions welcome, particularly other TTS APIs, check the issues beforehand and feel free to open a PR. Code is formatted with Black.

## Contributors

Special thanks to:

- [Mayank Vishwakarma](mailto:[email protected]) (@mayankwebbing)

## License

This project is licensed under the MIT License.
Expand Down
8 changes: 3 additions & 5 deletions joinery/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
class BaseTtsApi:
service: str = None

def __init__(self, model, voice, caching_enabled=True):
def __init__(self, model='tts-1', voice='alloy', caching_enabled=True):
self.caching_enabled = caching_enabled
self.model = model
self.voice = voice

if self.caching_enabled:
self.CACHE_DIR = user_data_dir("tts_joinery", "com.drien")
if not os.path.exists(self.CACHE_DIR):
os.mkdir(self.CACHE_DIR)
self.CACHE_DIR = user_data_dir("tts_joinery", "com.drien")
os.makedirs(self.CACHE_DIR, exist_ok=True)

def get_file_path(self, text: str) -> Path:
text_hash = hashlib.md5(text.encode("utf-8")).hexdigest()
Expand Down
2 changes: 1 addition & 1 deletion joinery/api/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, *args, api_key: Optional[str] = None, **kwargs):
def process_to_file(self, text: str) -> Path:
file_path = self.get_file_path(text)

if not self.caching_enabled or not os.path.exists(file_path):
if not self.caching_enabled or not file_path.exists():
with self.client.audio.speech.with_streaming_response.create(
model=self.model,
voice=self.voice,
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "tts-joinery"
version = "1.0.1"
version = "1.0.2"
authors = [
{name = "Adrien Delessert", email = "[email protected]"},
]
Expand All @@ -30,4 +30,4 @@ dependencies = [
ttsjoin = "joinery.cli:run_tts"

[project.urls]
Homepage = "https://github.com/drien/tts-joinery"
Homepage = "https://github.com/drien/tts-joinery"

0 comments on commit 567d518

Please sign in to comment.