Skip to content

Commit 68442ca

Browse files
authored
Merge pull request #132 from neuphonic/joh/multiling-cloning
Multilingual Cloning
2 parents 72f6299 + c174a97 commit 68442ca

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

pyneuphonic/_voices.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ def get(self, voice_id: str = None, voice_name: str = None) -> APIResponse[dict]
7878
return APIResponse(data=voice)
7979

8080
def clone(
81-
self, voice_name: str, voice_file_path: str, voice_tags: List[str] = []
81+
self,
82+
voice_name: str,
83+
voice_file_path: str,
84+
voice_tags: List[str] = [],
85+
lang_code: str = "en",
8286
) -> APIResponse[dict]:
8387
"""
8488
Clone a voice by uploading a file with the specified name and tags.
@@ -110,6 +114,7 @@ def clone(
110114
# Prepare the multipart form-data payload
111115
params = {
112116
"voice_tags": voice_tags,
117+
"lang_code": lang_code,
113118
}
114119
files = {"voice_file": open(voice_file_path, "rb")}
115120

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# POETRY CONFIG
22
[tool.poetry]
33
name = "pyneuphonic"
4-
version = "1.8.6"
4+
version = "1.8.7"
55
description = "A python SDK for the Neuphonic TTS Engine."
66
authors = ["Neuphonic <support@neuphonic.com>"]
77
readme = "README.md"

tests/test_unit.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ async def test_clone_voice(client: Neuphonic, mocker: MockerFixture):
132132
voice_name = "TestVoice-SDK"
133133
voice_tags = ["tag1", "tag2"]
134134
voice_tags_adapted = "tag1, tag2"
135+
lang_code = "en"
135136

136137
# Mock the file content
137138
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_file:
@@ -160,7 +161,9 @@ async def test_clone_voice(client: Neuphonic, mocker: MockerFixture):
160161
mock_post.return_value = mock_response
161162

162163
# Call the clone method
163-
response = client.voices.clone(voice_name, voice_file_path, voice_tags)
164+
response = client.voices.clone(
165+
voice_name, voice_file_path, voice_tags, lang_code
166+
)
164167

165168
# Assertions
166169
assert isinstance(response, APIResponse)
@@ -171,7 +174,7 @@ async def test_clone_voice(client: Neuphonic, mocker: MockerFixture):
171174
mock_post.assert_called_once_with(
172175
f"https://{base_url}/voices?voice_name={voice_name}",
173176
json=None,
174-
params={"voice_tags": voice_tags_adapted},
177+
params={"lang_code": "en", "voice_tags": voice_tags_adapted},
175178
files={"voice_file": mocker.ANY}, # Matches the file object
176179
headers={"x-api-key": mocker.ANY}, # Ensure the API key is present
177180
timeout=10,

0 commit comments

Comments
 (0)