Skip to content

Commit 6bb94e5

Browse files
committed
translate trigrams to pinyin
1 parent b57f69a commit 6bb94e5

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

packages/client-discord/src/voice.ts

+15-5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import {
5353
trigramFigures,
5454
trigramDescriptions,
5555
trigramChineseMapping,
56+
trigrams_named,
5657
} from "@ai16z/agent/data/hexagrams.ts";
5758

5859
// These values are chosen for compatibility with picovoice components
@@ -1049,18 +1050,27 @@ export class VoiceManager extends EventEmitter {
10491050
}
10501051

10511052
private translateIdeograms(text: string): string {
1052-
// Create reverse mappings
1053+
// Create element to pinyin mapping
1054+
const elementToPinyin = Object.entries(trigrams_named).reduce(
1055+
(acc, [pinyin, data]) => {
1056+
acc[data.element] = pinyin;
1057+
return acc;
1058+
},
1059+
{} as Record<string, string>
1060+
);
1061+
1062+
// Create reverse mappings using pinyin instead of element names
10531063
const trigramByFigure = Object.entries(trigramFigures).reduce(
1054-
(acc, [name, figure]) => {
1055-
acc[figure] = name;
1064+
(acc, [element, figure]) => {
1065+
acc[figure] = elementToPinyin[element];
10561066
return acc;
10571067
},
10581068
{} as Record<string, string>
10591069
);
10601070

10611071
const trigramByChinese = Object.entries(trigramChineseMapping).reduce(
1062-
(acc, [name, chinese]) => {
1063-
acc[chinese] = name;
1072+
(acc, [element, chinese]) => {
1073+
acc[chinese] = elementToPinyin[element];
10641074
return acc;
10651075
},
10661076
{} as Record<string, string>

0 commit comments

Comments
 (0)