-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
67 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "Util.h" | ||
#include <algorithm> | ||
#include <regex> | ||
|
||
|
||
bool IsSsml(const std::string& str) { | ||
std::string cpy_str = str; | ||
cpy_str.erase(std::remove_if(cpy_str.begin(), cpy_str.end(), ::isspace), cpy_str.end()); | ||
size_t pos = cpy_str.find("<speak>"); | ||
if (pos == 0 && cpy_str.find("</speak>") != std::string::npos) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
bool AddSsml(std::string& str) { | ||
if (IsSsml(str))return true; | ||
str = "<speak>" + str + "</speak>"; | ||
return IsSsml(str); | ||
} | ||
bool RemoveSsml(std::string& str) { | ||
if (!IsSsml(str))return true; | ||
std::regex ssml_tags("<[^>]+>"); | ||
str = std::regex_replace(str, ssml_tags, ""); // Replace SSML tags with an empty string | ||
return true; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef UTIL_H_ | ||
#define UTIL_H_ | ||
#include <string> | ||
bool IsSsml(const std::string& str); | ||
bool AddSsml(std::string& str); | ||
bool RemoveSsml(std::string& str); | ||
#endif |