Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 6 additions & 1 deletion pyneuphonic/_voices.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ def get(self, voice_id: str = None, voice_name: str = None) -> APIResponse[dict]
return APIResponse(data=voice)

def clone(
self, voice_name: str, voice_file_path: str, voice_tags: List[str] = []
self,
voice_name: str,
voice_file_path: str,
voice_tags: List[str] = [],
lang_code: str = "en",
) -> APIResponse[dict]:
"""
Clone a voice by uploading a file with the specified name and tags.
Expand Down Expand Up @@ -123,6 +127,7 @@ def clone(
# Prepare the multipart form-data payload
params = {
"voice_tags": voice_tags,
"lang_code": lang_code,
}
files = {"voice_file": open(voice_file_path, "rb")}

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# POETRY CONFIG
[tool.poetry]
name = "pyneuphonic"
version = "1.8.5"
version = "1.8.7"
description = "A python SDK for the Neuphonic TTS Engine."
authors = ["Neuphonic <support@neuphonic.com>"]
readme = "README.md"
Expand Down
7 changes: 5 additions & 2 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ async def test_clone_voice(client: Neuphonic, mocker: MockerFixture):
voice_name = "TestVoice-SDK"
voice_tags = ["tag1", "tag2"]
voice_tags_adapted = "tag1, tag2"
lang_code = "en"

# Mock the file content
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_file:
Expand Down Expand Up @@ -162,7 +163,9 @@ async def test_clone_voice(client: Neuphonic, mocker: MockerFixture):
mock_post.return_value = mock_response

# Call the clone method
response = client.voices.clone(voice_name, voice_file_path, voice_tags)
response = client.voices.clone(
voice_name, voice_file_path, voice_tags, lang_code
)

# Assertions
assert isinstance(response, APIResponse)
Expand All @@ -172,7 +175,7 @@ async def test_clone_voice(client: Neuphonic, mocker: MockerFixture):
base_url = os.getenv("NEUPHONIC_API_URL", "default-api-url")
mock_post.assert_called_once_with(
f"https://{base_url}/voices?voice_name={voice_name}",
params={"voice_tags": voice_tags_adapted},
params={"lang_code": "en", "voice_tags": voice_tags_adapted},
files={"voice_file": mocker.ANY}, # Matches the file object
headers={"x-api-key": mocker.ANY}, # Ensure the API key is present
timeout=10,
Expand Down