@aituber-onair/core 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils/screenplay.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* Extract emotion from text using regex
|
|
3
3
|
* Extract emotion from text written in the format [happy], [sad], etc.
|
|
4
4
|
*/
|
|
5
|
-
const EMOTION_REGEX =
|
|
5
|
+
const EMOTION_REGEX = /\[([a-z]+)\]/i;
|
|
6
|
+
const EMOTION_CLEANUP_REGEX = /\[[a-z]+\]\s*/gi;
|
|
6
7
|
/**
|
|
7
8
|
* Convert text to screenplay (text with emotion)
|
|
8
9
|
* @param text Original text (may contain emotion expressions like [happy])
|
|
@@ -12,7 +13,8 @@ export function textToScreenplay(text) {
|
|
|
12
13
|
const match = text.match(EMOTION_REGEX);
|
|
13
14
|
if (match) {
|
|
14
15
|
const emotion = match[1].toLowerCase();
|
|
15
|
-
|
|
16
|
+
// Remove all emotion tags from the text and trim whitespace
|
|
17
|
+
const cleanText = text.replace(EMOTION_CLEANUP_REGEX, '').trim();
|
|
16
18
|
return {
|
|
17
19
|
emotion,
|
|
18
20
|
text: cleanText,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenplay.js","sourceRoot":"","sources":["../../src/utils/screenplay.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"screenplay.js","sourceRoot":"","sources":["../../src/utils/screenplay.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,aAAa,GAAG,eAAe,CAAC;AACtC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAExC,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACvC,4DAA4D;QAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACjE,OAAO;YACL,OAAO;YACP,IAAI,EAAE,SAAS;SAChB,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAe;IAC/C,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAsB;IACrD,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;QACvB,OAAO,IAAI,UAAU,CAAC,OAAO,KAAK,UAAU,CAAC,IAAI,EAAE,CAAC;IACtD,CAAC;IACD,OAAO,UAAU,CAAC,IAAI,CAAC;AACzB,CAAC"}
|