Skip to content

Commit

Permalink
Update custom voice API sample code. (#2217)
Browse files Browse the repository at this point in the history
1. Add clean up code in personal voice sample.
2. Fix 2 issues
   Lite recipe is private. Hide it.
   Remove a hard code speaker_profile_id, which is checked in by mistake before.

Co-authored-by: Jun-wei Gan <[email protected]>
Co-authored-by: Yulin Li <[email protected]>
  • Loading branch information
3 people authored Jan 16, 2024
1 parent 79c7f9f commit 7905461
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion samples/custom-voice/python/customvoice/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RecipeKind(Enum):
Default = 1
CrossLingual = 2
MultiStyle = 3
Lite = 4
# Lite = 4


class Model(StatusObject):
Expand Down
9 changes: 8 additions & 1 deletion samples/custom-voice/python/personal_voice_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def speech_synthesis_to_wave_file(text: str, output_file_path: str, speaker_prof
print("result id: {}".format(result.result_id))


def clean_up(project_id: str, consent_id: str, personal_voice_id: str):
customvoice.PersonalVoice.delete(config, personal_voice_id)
customvoice.Consent.delete(config, consent_id)
customvoice.Project.delete(config, project_id)


region = 'eastus' # eastus, westeurope, southeastasia
key = '<put your speech accout key here>'
Expand Down Expand Up @@ -100,9 +105,11 @@ def speech_synthesis_to_wave_file(text: str, output_file_path: str, speaker_prof
speaker_profile_id = create_personal_voice(project_id,
consent_id, consent_file_path, voice_talent_name, company_name,
personal_voice_id, audio_folder)
speaker_profile_id = '693c7bb4-5945-4e99-bde9-1c06f95b46fb'

# step 2: synthesis wave
text = 'This is zero shot voice. Test 2.'
output_wave_file_path = 'D:\CNV_API\output_1.wav'
speech_synthesis_to_wave_file(text, output_wave_file_path, speaker_profile_id)

# Optional step 3: clean up, if you don't need this voice to synthesis more content.
clean_up(project_id, consent_id, personal_voice_id)

0 comments on commit 7905461

Please sign in to comment.