Skip to content

Commit

Permalink
Enable to play AnimatedSay from JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
uezo committed Aug 1, 2020
1 parent 9bffcd1 commit 1a5930e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ChatdollKit/Scripts/Model/ModelController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,30 @@ public async Task AnimatedSay(AnimatedVoiceRequest request, CancellationToken to
}
}

// AnimatedSay from JSON file
public async Task AnimatedSay(string filePath, CancellationToken token)
{
AnimatedVoiceRequest animatedVoiceRequest;

try
{
var jsonString = string.Empty;
using (var reader = File.OpenText(filePath))
{
jsonString = await reader.ReadToEndAsync();
}

animatedVoiceRequest = JsonConvert.DeserializeObject<AnimatedVoiceRequest>(jsonString);
}
catch (Exception ex)
{
Debug.LogError($"Error occured in AnimatedSay from file {filePath}: {ex.Message}\n{ex.StackTrace}");
return;
}

await AnimatedSay(animatedVoiceRequest, token);
}

// Speak one phrase
public async Task Say(string voiceName, float preGap = 0f, float postGap = 0f)
{
Expand Down

0 comments on commit 1a5930e

Please sign in to comment.