Skip to content

Commit

Permalink
Merge pull request #357 from deepgram/fix/string-parsing
Browse files Browse the repository at this point in the history
fix: handle double quotes and new lines
  • Loading branch information
naomi-lgbt authored Dec 19, 2024
2 parents bd83caf + f678f39 commit 4c9955d
Show file tree
Hide file tree
Showing 4 changed files with 2,571 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Deepgram/Clients/Speak/v2/WebSocket/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,12 @@ public async Task<bool> Subscribe(EventHandler<UnhandledResponse> eventHandler)
/// <param name="text">The string of text you want to be converted to audio.</param>
public void SpeakWithText(string text)
{
TextSource textSource = new TextSource(text);
TextSource textSource = new TextSource(text.Replace("\r\n", "\\n")
.Replace("\n", "\\n")
.Replace("\"", "\\\"")
.Replace("\b", "\\b")
.Replace("\f", "\\f")
.Replace("\t", "\\t"));
byte[] byteArray = Encoding.UTF8.GetBytes(textSource.ToString());
SendMessage(byteArray);
}
Expand Down
Loading

0 comments on commit 4c9955d

Please sign in to comment.