@@ -39,6 +39,11 @@ import { stringToUuid } from "@ai16z/eliza";
39
39
import { rateLimiter } from "./messages" ;
40
40
import { embeddingConfig } from "@ai16z/eliza" ;
41
41
import { VoiceConnectionStatus } from "@discordjs/voice" ;
42
+ import {
43
+ hexagramData ,
44
+ trigramFigures ,
45
+ trigramDescriptions ,
46
+ } from "@ai16z/agent/data/hexagrams.ts" ;
42
47
// Voice-specific rate limiter
43
48
export const voiceRateLimiter = {
44
49
lastCall : 0 ,
@@ -826,9 +831,26 @@ export class VoiceManager extends EventEmitter {
826
831
} ;
827
832
828
833
if ( responseMemory . content . text ?. trim ( ) ) {
829
- // Filter out I-Ching hexagrams before speech generation
834
+ // Replace I-Ching hexagrams with their English meanings before speech generation
830
835
const textForSpeech = content . text
831
- . replace ( / [ ䷀ - ䷿ ] / g, "" )
836
+ . replace ( / [ ䷀ - ䷿ ] / g, ( match ) => {
837
+ const hexagram = hexagramData . find (
838
+ ( h ) => h . unicode === match
839
+ ) ;
840
+ return hexagram
841
+ ? `[${ hexagram . meaning } ]`
842
+ : "" ;
843
+ } )
844
+ . replace ( / [ ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ ] / g, ( match ) => {
845
+ const trigram = Object . entries (
846
+ trigramFigures
847
+ ) . find (
848
+ ( [ _ , figure ] ) => figure === match
849
+ ) ;
850
+ return trigram
851
+ ? `[${ trigramDescriptions [ trigram [ 0 ] ] } ]`
852
+ : "" ;
853
+ } )
832
854
. trim ( ) ;
833
855
834
856
const canProcessNow =
@@ -978,7 +1000,7 @@ export class VoiceManager extends EventEmitter {
978
1000
return true ;
979
1001
}
980
1002
981
- const loseInterestWords = [
1003
+ const interruptWords = [
982
1004
// telling the bot to stop talking
983
1005
"shut up" ,
984
1006
"stop" ,
@@ -990,21 +1012,11 @@ export class VoiceManager extends EventEmitter {
990
1012
"stfu" ,
991
1013
"stupid bot" ,
992
1014
"dumb bot" ,
993
-
994
- // offensive words
995
- "fuck" ,
996
- "shit" ,
997
- "damn" ,
998
- "suck" ,
999
- "dick" ,
1000
- "cock" ,
1001
- "sex" ,
1002
- "sexy" ,
1003
1015
] ;
1004
1016
1005
1017
// Check for interrupt words
1006
1018
if (
1007
- loseInterestWords . some ( ( word ) =>
1019
+ interruptWords . some ( ( word ) =>
1008
1020
( message . content as Content ) . text ?. toLowerCase ( ) . includes ( word )
1009
1021
)
1010
1022
) {
@@ -1014,7 +1026,29 @@ export class VoiceManager extends EventEmitter {
1014
1026
1015
1027
if (
1016
1028
( message . content as Content ) . text . length < 50 &&
1017
- loseInterestWords . some ( ( word ) =>
1029
+ interruptWords . some ( ( word ) =>
1030
+ ( message . content as Content ) . text ?. toLowerCase ( ) . includes ( word )
1031
+ )
1032
+ ) {
1033
+ return true ;
1034
+ }
1035
+
1036
+ const offensiveWords = [
1037
+ "stupid bot" ,
1038
+ "dumb bot" ,
1039
+ "fuck" ,
1040
+ "shit" ,
1041
+ "damn" ,
1042
+ "suck" ,
1043
+ "dick" ,
1044
+ "cock" ,
1045
+ "sex" ,
1046
+ "sexy" ,
1047
+ ] ;
1048
+
1049
+ if (
1050
+ ( message . content as Content ) . text . length < 50 &&
1051
+ offensiveWords . some ( ( word ) =>
1018
1052
( message . content as Content ) . text ?. toLowerCase ( ) . includes ( word )
1019
1053
)
1020
1054
) {
0 commit comments