Skip to content

Commit

Permalink
com.rest.elevenlabs 2.0.5 (#25)
Browse files Browse the repository at this point in the history
- updated voice settings
  - added speaker boost and style options
  • Loading branch information
StephenHodgson committed Jul 14, 2023
1 parent c141547 commit 5b270bb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,10 @@ private static GUIStyle BoldCenteredHeaderStyle
private string currentModelId;

[SerializeField]
private Vector2 voiceSettingsSliderValues = Vector2.zero;
private Vector3 voiceSettingsSliderValues = Vector3.zero;

[SerializeField]
private bool useSpeakerBoost = true;

[SerializeField]
private List<AudioClip> newSampleClips;
Expand Down Expand Up @@ -823,7 +826,7 @@ private void RenderSpeechSynthesis()
}

if (currentVoiceSettings == null ||
voiceSettingsSliderValues == Vector2.zero)
voiceSettingsSliderValues == Vector3.zero)
{
GetDefaultVoiceSettings(currentVoiceOption);
}
Expand Down Expand Up @@ -871,6 +874,21 @@ private void RenderSpeechSynthesis()
EndIndent(InnerLabelIndentLevel);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space(EndWidth);
voiceSettingsSliderValues.z = EditorGUILayout.Slider("Style", voiceSettingsSliderValues.z, 0f, 1f);
EditorGUILayout.BeginHorizontal();
{
StartIndent(InnerLabelIndentLevel);
EditorGUIUtility.labelWidth = WideColumnWidth * InnerLabelWidth;
EditorGUILayout.LabelField("Low", expandWidthOption);
GUILayout.FlexibleSpace();
EditorGUILayout.LabelField("High", RightMiddleAlignedLabel, expandWidthOption);
EditorGUIUtility.labelWidth = WideColumnWidth * SettingsLabelWidth;
EndIndent(InnerLabelIndentLevel);
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.Space(EndWidth);
useSpeakerBoost = EditorGUILayout.Toggle("Speaker Boost", useSpeakerBoost);
EditorGUILayout.Space();
}

Expand Down Expand Up @@ -921,7 +939,7 @@ private void RenderSpeechSynthesis()

if (EditorGUI.EndChangeCheck())
{
currentVoiceSettings = new VoiceSettings(voiceSettingsSliderValues.x, voiceSettingsSliderValues.y);
currentVoiceSettings = new VoiceSettings(voiceSettingsSliderValues.x, voiceSettingsSliderValues.y, useSpeakerBoost, voiceSettingsSliderValues.z);
}

EditorGUILayout.EndHorizontal();
Expand Down Expand Up @@ -1052,7 +1070,8 @@ private async void GetDefaultVoiceSettings(Voice voice)
var defaultVoiceSettings = await api.VoicesEndpoint.GetDefaultVoiceSettingsAsync();
await api.VoicesEndpoint.EditVoiceSettingsAsync(voice, defaultVoiceSettings);
currentVoiceSettings = await api.VoicesEndpoint.GetVoiceSettingsAsync(voice);
voiceSettingsSliderValues = new Vector2(defaultVoiceSettings.Stability, defaultVoiceSettings.SimilarityBoost);
voiceSettingsSliderValues = new Vector3(defaultVoiceSettings.Stability, defaultVoiceSettings.SimilarityBoost, 0.45f);
useSpeakerBoost = true;
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ public sealed class VoiceSettings
[JsonConstructor]
public VoiceSettings(
[JsonProperty("stability")] float stability,
[JsonProperty("similarity_boost")] float similarityBoost)
[JsonProperty("similarity_boost")] float similarityBoost,
[JsonProperty("speaker_boost")] bool speakerBoost = true,
[JsonProperty("style")] float style = 0.45f)
{
Stability = stability;
SimilarityBoost = similarityBoost;
SpeakerBoost = speakerBoost;
Style = style;
}

[Range(0f, 1f)]
Expand All @@ -44,5 +48,28 @@ public float SimilarityBoost
get => similarityBoost;
private set => similarityBoost = value;
}

[Range(0f, 1f)]
[SerializeField]
private float style = 0.45f;

[Preserve]
[JsonProperty("style")]
public float Style
{
get => style;
set => style = value;
}

[SerializeField]
private bool speakerBoost = true;

[Preserve]
[JsonProperty("use_speaker_boost")]
public bool SpeakerBoost
{
get => speakerBoost;
set => speakerBoost = value;
}
}
}
2 changes: 1 addition & 1 deletion ElevenLabs/Packages/com.rest.elevenlabs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "ElevenLabs",
"description": "A non-official Eleven Labs voice synthesis RESTful client.",
"keywords": [],
"version": "2.0.4",
"version": "2.0.5",
"unity": "2021.3",
"documentationUrl": "https://github.com/RageAgainstThePixel/com.rest.elevenlabs#documentation",
"changelogUrl": "https://github.com/RageAgainstThePixel/com.rest.elevenlabs/releases",
Expand Down

0 comments on commit 5b270bb

Please sign in to comment.