@fugood/bricks-ctor 2.24.0-beta.40

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.
Files changed (129) hide show
  1. package/compile/action-name-map.ts +988 -0
  2. package/compile/index.ts +1245 -0
  3. package/compile/util.ts +358 -0
  4. package/index.ts +6 -0
  5. package/package.json +28 -0
  6. package/skills/bricks-design/LICENSE.txt +180 -0
  7. package/skills/bricks-design/SKILL.md +66 -0
  8. package/skills/bricks-project/SKILL.md +32 -0
  9. package/skills/bricks-project/rules/animation.md +159 -0
  10. package/skills/bricks-project/rules/architecture-patterns.md +69 -0
  11. package/skills/bricks-project/rules/automations.md +221 -0
  12. package/skills/bricks-project/rules/buttress.md +156 -0
  13. package/skills/bricks-project/rules/data-calculation.md +208 -0
  14. package/skills/bricks-project/rules/local-sync.md +129 -0
  15. package/skills/bricks-project/rules/media-flow.md +158 -0
  16. package/skills/bricks-project/rules/remote-data-bank.md +196 -0
  17. package/skills/bricks-project/rules/standby-transition.md +124 -0
  18. package/skills/rive-marketplace/SKILL.md +99 -0
  19. package/tools/deploy.ts +151 -0
  20. package/tools/icons/.gitattributes +1 -0
  21. package/tools/icons/fa6pro-glyphmap.json +4686 -0
  22. package/tools/icons/fa6pro-meta.json +3671 -0
  23. package/tools/mcp-server.ts +28 -0
  24. package/tools/mcp-tools/compile.ts +91 -0
  25. package/tools/mcp-tools/huggingface.ts +762 -0
  26. package/tools/mcp-tools/icons.ts +70 -0
  27. package/tools/mcp-tools/lottie.ts +102 -0
  28. package/tools/mcp-tools/media.ts +110 -0
  29. package/tools/postinstall.ts +229 -0
  30. package/tools/preview-main.mjs +293 -0
  31. package/tools/preview.ts +143 -0
  32. package/tools/pull.ts +116 -0
  33. package/tsconfig.json +16 -0
  34. package/types/animation.ts +100 -0
  35. package/types/automation.ts +235 -0
  36. package/types/brick-base.ts +80 -0
  37. package/types/bricks/Camera.ts +246 -0
  38. package/types/bricks/Chart.ts +372 -0
  39. package/types/bricks/GenerativeMedia.ts +276 -0
  40. package/types/bricks/Icon.ts +98 -0
  41. package/types/bricks/Image.ts +114 -0
  42. package/types/bricks/Items.ts +476 -0
  43. package/types/bricks/Lottie.ts +168 -0
  44. package/types/bricks/Maps.ts +262 -0
  45. package/types/bricks/QrCode.ts +117 -0
  46. package/types/bricks/Rect.ts +150 -0
  47. package/types/bricks/RichText.ts +128 -0
  48. package/types/bricks/Rive.ts +220 -0
  49. package/types/bricks/Slideshow.ts +201 -0
  50. package/types/bricks/Svg.ts +99 -0
  51. package/types/bricks/Text.ts +148 -0
  52. package/types/bricks/TextInput.ts +242 -0
  53. package/types/bricks/Video.ts +175 -0
  54. package/types/bricks/VideoStreaming.ts +112 -0
  55. package/types/bricks/WebRtcStream.ts +65 -0
  56. package/types/bricks/WebView.ts +168 -0
  57. package/types/bricks/index.ts +21 -0
  58. package/types/canvas.ts +82 -0
  59. package/types/common.ts +144 -0
  60. package/types/data-calc-command.ts +7005 -0
  61. package/types/data-calc-script.ts +21 -0
  62. package/types/data-calc.ts +11 -0
  63. package/types/data.ts +95 -0
  64. package/types/generators/AlarmClock.ts +110 -0
  65. package/types/generators/Assistant.ts +621 -0
  66. package/types/generators/BleCentral.ts +247 -0
  67. package/types/generators/BlePeripheral.ts +208 -0
  68. package/types/generators/CanvasMap.ts +74 -0
  69. package/types/generators/CastlesPay.ts +87 -0
  70. package/types/generators/DataBank.ts +160 -0
  71. package/types/generators/File.ts +432 -0
  72. package/types/generators/GraphQl.ts +132 -0
  73. package/types/generators/Http.ts +222 -0
  74. package/types/generators/HttpServer.ts +176 -0
  75. package/types/generators/Information.ts +103 -0
  76. package/types/generators/Intent.ts +168 -0
  77. package/types/generators/Iterator.ts +108 -0
  78. package/types/generators/Keyboard.ts +105 -0
  79. package/types/generators/LlmAnthropicCompat.ts +212 -0
  80. package/types/generators/LlmAppleBuiltin.ts +159 -0
  81. package/types/generators/LlmGgml.ts +861 -0
  82. package/types/generators/LlmMediaTekNeuroPilot.ts +235 -0
  83. package/types/generators/LlmMlx.ts +227 -0
  84. package/types/generators/LlmOnnx.ts +213 -0
  85. package/types/generators/LlmOpenAiCompat.ts +244 -0
  86. package/types/generators/LlmQualcommAiEngine.ts +247 -0
  87. package/types/generators/Mcp.ts +637 -0
  88. package/types/generators/McpServer.ts +289 -0
  89. package/types/generators/MediaFlow.ts +170 -0
  90. package/types/generators/MqttBroker.ts +141 -0
  91. package/types/generators/MqttClient.ts +141 -0
  92. package/types/generators/Question.ts +408 -0
  93. package/types/generators/RealtimeTranscription.ts +279 -0
  94. package/types/generators/RerankerGgml.ts +191 -0
  95. package/types/generators/SerialPort.ts +151 -0
  96. package/types/generators/SoundPlayer.ts +94 -0
  97. package/types/generators/SoundRecorder.ts +130 -0
  98. package/types/generators/SpeechToTextGgml.ts +415 -0
  99. package/types/generators/SpeechToTextOnnx.ts +236 -0
  100. package/types/generators/SpeechToTextPlatform.ts +85 -0
  101. package/types/generators/SqLite.ts +159 -0
  102. package/types/generators/Step.ts +107 -0
  103. package/types/generators/SttAppleBuiltin.ts +130 -0
  104. package/types/generators/Tcp.ts +126 -0
  105. package/types/generators/TcpServer.ts +147 -0
  106. package/types/generators/TextToSpeechAppleBuiltin.ts +127 -0
  107. package/types/generators/TextToSpeechGgml.ts +221 -0
  108. package/types/generators/TextToSpeechOnnx.ts +178 -0
  109. package/types/generators/TextToSpeechOpenAiLike.ts +121 -0
  110. package/types/generators/ThermalPrinter.ts +191 -0
  111. package/types/generators/Tick.ts +83 -0
  112. package/types/generators/Udp.ts +120 -0
  113. package/types/generators/VadGgml.ts +250 -0
  114. package/types/generators/VadOnnx.ts +231 -0
  115. package/types/generators/VadTraditional.ts +138 -0
  116. package/types/generators/VectorStore.ts +257 -0
  117. package/types/generators/Watchdog.ts +107 -0
  118. package/types/generators/WebCrawler.ts +103 -0
  119. package/types/generators/WebRtc.ts +181 -0
  120. package/types/generators/WebSocket.ts +148 -0
  121. package/types/generators/index.ts +57 -0
  122. package/types/index.ts +13 -0
  123. package/types/subspace.ts +59 -0
  124. package/types/switch.ts +51 -0
  125. package/types/system.ts +707 -0
  126. package/utils/calc.ts +126 -0
  127. package/utils/data.ts +497 -0
  128. package/utils/event-props.ts +836 -0
  129. package/utils/id.ts +80 -0
@@ -0,0 +1,221 @@
1
+ /* Auto generated by build script
2
+ *
3
+ * Local Text-to-Speech (TTS) inference based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
4
+ * You can use any converted model on HuggingFace.
5
+ *
6
+ * ## Notice
7
+ * - The device RAM must be larger than 8GB
8
+ * - iOS: Recommended use M1+ / A17+ chip device. Supported GPU acceleration by Metal.
9
+ * - macOS: Recommended use M1+ chip device. Supported GPU acceleration by Metal.
10
+ * - Android: Recommended use Android 13+ system.
11
+ * - Supported GPU acceleration by OpenCL, currently only for Qualcomm Adreno 700+ GPUs, other GPUs are not supported.
12
+ * - Supported Hexagon NPU for Qualcomm Snapdragon 8 Gen 2+ GPUs.
13
+ * - Linux / Windows
14
+ * - Supported GPU acceleration, you can choose `vulkan` or `cuda` backend in Accel Variant property
15
+ * - Supported Hexagon NPU for Qualcomm Dragonwing IQ9 series+ (Linux)
16
+ */
17
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
18
+ import type { Data, DataLink } from '../data'
19
+ import type {
20
+ Brick,
21
+ Generator,
22
+ EventAction,
23
+ ActionWithDataParams,
24
+ ActionWithParams,
25
+ Action,
26
+ EventProperty,
27
+ } from '../common'
28
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
29
+
30
+ /* Load the model */
31
+ export type GeneratorGGMLTTSActionLoadModel = Action & {
32
+ __actionName: 'GENERATOR_GGML_TTS_LOAD_MODEL'
33
+ }
34
+
35
+ /* Generate audio */
36
+ export type GeneratorGGMLTTSActionGenerate = ActionWithParams & {
37
+ __actionName: 'GENERATOR_GGML_TTS_GENERATE'
38
+ params?: Array<{
39
+ input: 'text'
40
+ value?: string | DataLink | EventProperty
41
+ mapping?: string
42
+ }>
43
+ }
44
+
45
+ /* Clean cache */
46
+ export type GeneratorGGMLTTSActionCleanCache = Action & {
47
+ __actionName: 'GENERATOR_GGML_TTS_CLEAN_CACHE'
48
+ }
49
+
50
+ /* Release context */
51
+ export type GeneratorGGMLTTSActionReleaseContext = Action & {
52
+ __actionName: 'GENERATOR_GGML_TTS_RELEASE_CONTEXT'
53
+ }
54
+
55
+ /* Cancel current generation and clear queue */
56
+ export type GeneratorGGMLTTSActionCancel = Action & {
57
+ __actionName: 'GENERATOR_GGML_TTS_CANCEL'
58
+ }
59
+
60
+ interface GeneratorGGMLTTSDef {
61
+ /*
62
+ Default property:
63
+ {
64
+ "vocoderUrl": "https://huggingface.co/ggml-org/WavTokenizer/resolve/main/WavTokenizer-Large-75-F16.gguf",
65
+ "vocoderHashType": "sha256",
66
+ "vocoderHash": "2356baa8631cc2995ea3465196a017a2733600d849a91180c0f97fa7fb375bbe",
67
+ "vocoderBatchSize": 4096,
68
+ "outputType": "play",
69
+ "cacheGenerated": true,
70
+ "autoInferEnable": false,
71
+ "softBreakRegex": "^[^\\r\\n\\t\\f\\v]*([\\r\\n]+|[。!?!?.]\\B)",
72
+ "hardBreakTime": 500,
73
+ "completionTemperature": 0.1,
74
+ "completionRepetitionPenalty": 1.1,
75
+ "completionTopK": 40,
76
+ "completionTopP": 0.9,
77
+ "completionMinP": 0.05,
78
+ "useGuideToken": true,
79
+ "contextSize": 8192,
80
+ "batchSize": 8192,
81
+ "microBatchSize": 512,
82
+ "maxThreads": 2,
83
+ "accelVariant": "default",
84
+ "mainGpu": 0,
85
+ "gpuLayers": 0,
86
+ "useMlock": true,
87
+ "useMmap": true,
88
+ "useFlashAttn": "off"
89
+ }
90
+ */
91
+ property?: {
92
+ /* Initialize the TTS context on generator initialization */
93
+ init?: boolean | DataLink
94
+ /* The URL or path of model
95
+ We used GGUF format model, please refer to https://github.com/ggerganov/llama.cpp/tree/master#description */
96
+ modelUrl?: string | DataLink
97
+ /* Hash type of model */
98
+ modelHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
99
+ /* Hash of model */
100
+ modelHash?: string | DataLink
101
+ /* The URL or path of vocoder model */
102
+ vocoderUrl?: string | DataLink
103
+ /* Hash type of vocoder model */
104
+ vocoderHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
105
+ /* Hash of vocoder model */
106
+ vocoderHash?: string | DataLink
107
+ /* Batch size of vocoder model */
108
+ vocoderBatchSize?: number | DataLink
109
+ /* Output mode */
110
+ outputType?: 'play' | 'file' | DataLink
111
+ /* Enable cache for generated audio */
112
+ cacheGenerated?: boolean | DataLink
113
+ /* Text to generate */
114
+ prompt?: string | DataLink
115
+ /* Speaker JSON */
116
+ speaker?: {} | DataLink
117
+ /* Auto inference when prompt changes */
118
+ autoInferEnable?: boolean | DataLink
119
+ /* Segmentation rule for auto inference */
120
+ softBreakRegex?: string | DataLink
121
+ /* Time to force inference when softBreakRegex is not satisfied */
122
+ hardBreakTime?: number | DataLink
123
+ /* Temperature */
124
+ completionTemperature?: number | DataLink
125
+ /* Repetition Penalty */
126
+ completionRepetitionPenalty?: number | DataLink
127
+ /* Top K sampling */
128
+ completionTopK?: number | DataLink
129
+ /* Top P sampling */
130
+ completionTopP?: number | DataLink
131
+ /* Min P sampling */
132
+ completionMinP?: number | DataLink
133
+ /* Set the random number generator (RNG) seed (default: -1, -1 = random seed) */
134
+ completionSeed?: number | DataLink
135
+ /* Number of tokens to predict */
136
+ completionPredict?: number | DataLink
137
+ /* Enable guide token to help prevent hallucinations by forcing the TTS to use the correct words. */
138
+ useGuideToken?: boolean | DataLink
139
+ /* Context size, for OutTTS recommended 4096 ~ 8192 (Default to 4096) */
140
+ contextSize?: number | DataLink
141
+ /* Logical batch size for prompt processing */
142
+ batchSize?: number | DataLink
143
+ /* Physical batch size for prompt processing */
144
+ microBatchSize?: number | DataLink
145
+ /* Number of threads */
146
+ maxThreads?: number | DataLink
147
+ /* Accelerator variant (Only for desktop)
148
+ `default` - CPU / Metal (macOS)
149
+ `vulkan` - Use Vulkan
150
+ `cuda` - Use CUDA
151
+ `snapdragon` - Use OpenCL/Hexagon of Qualcomm Snapdragon */
152
+ accelVariant?: 'default' | 'vulkan' | 'cuda' | 'snapdragon' | DataLink
153
+ /* Devices. For example:
154
+
155
+ Metal or CPU for iOS/tvOS/MacOS
156
+ OpenCL or CPU for Android
157
+ - Add `HTP0`, `HTP1`, `...` for OpenCL/Hexagon devices (Use HTP* for all HTP devices)
158
+ For Desktop, you may want to include/exclude GPUs */
159
+ devices?: Array<string | DataLink> | DataLink
160
+ /* Main GPU index */
161
+ mainGpu?: number | DataLink
162
+ /* Number of GPU layers (NOTE: Currently not supported for Android) */
163
+ gpuLayers?: number | DataLink
164
+ /* Use memory lock */
165
+ useMlock?: boolean | DataLink
166
+ /* Use mmap */
167
+ useMmap?: boolean | DataLink
168
+ /* Use Flash Attention for inference (Recommended with GPU enabled) */
169
+ useFlashAttn?: 'auto' | 'on' | 'off' | DataLink
170
+ }
171
+ events?: {
172
+ /* Event triggered when state change */
173
+ onContextStateChange?: Array<
174
+ EventAction<string & keyof TemplateEventPropsMap['GgmlTts']['onContextStateChange']>
175
+ >
176
+ /* Event triggered when error occurs */
177
+ onError?: Array<EventAction<string & keyof TemplateEventPropsMap['GgmlTts']['onError']>>
178
+ }
179
+ outlets?: {
180
+ /* Context state */
181
+ contextState?: () => Data<string>
182
+ /* Generated audio file */
183
+ generatedAudio?: () => Data<string>
184
+ /* Generated audio file is playing */
185
+ generatedAudioPlaying?: () => Data<boolean>
186
+ }
187
+ }
188
+
189
+ /* Local Text-to-Speech (TTS) inference based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
190
+ You can use any converted model on HuggingFace.
191
+
192
+ ## Notice
193
+ - The device RAM must be larger than 8GB
194
+ - iOS: Recommended use M1+ / A17+ chip device. Supported GPU acceleration by Metal.
195
+ - macOS: Recommended use M1+ chip device. Supported GPU acceleration by Metal.
196
+ - Android: Recommended use Android 13+ system.
197
+ - Supported GPU acceleration by OpenCL, currently only for Qualcomm Adreno 700+ GPUs, other GPUs are not supported.
198
+ - Supported Hexagon NPU for Qualcomm Snapdragon 8 Gen 2+ GPUs.
199
+ - Linux / Windows
200
+ - Supported GPU acceleration, you can choose `vulkan` or `cuda` backend in Accel Variant property
201
+ - Supported Hexagon NPU for Qualcomm Dragonwing IQ9 series+ (Linux) */
202
+ export type GeneratorGGMLTTS = Generator &
203
+ GeneratorGGMLTTSDef & {
204
+ templateKey: 'GENERATOR_GGML_TTS'
205
+ switches?: Array<
206
+ SwitchDef &
207
+ GeneratorGGMLTTSDef & {
208
+ conds?: Array<{
209
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
210
+ cond:
211
+ | SwitchCondInnerStateCurrentCanvas
212
+ | SwitchCondData
213
+ | {
214
+ __typename: 'SwitchCondInnerStateOutlet'
215
+ outlet: 'contextState' | 'generatedAudio' | 'generatedAudioPlaying'
216
+ value: any
217
+ }
218
+ }>
219
+ }
220
+ >
221
+ }
@@ -0,0 +1,178 @@
1
+ /* Auto generated by build script
2
+ *
3
+ * Local Text-to-Speech (TTS) inference based on ONNX Runtime and [transformers.js](https://huggingface.co/docs/transformers.js)
4
+ * You can use any converted model on HuggingFace.
5
+ */
6
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
7
+ import type { Data, DataLink } from '../data'
8
+ import type {
9
+ Brick,
10
+ Generator,
11
+ EventAction,
12
+ ActionWithDataParams,
13
+ ActionWithParams,
14
+ Action,
15
+ EventProperty,
16
+ } from '../common'
17
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
18
+
19
+ /* Load the model */
20
+ export type GeneratorTTSActionLoadModel = Action & {
21
+ __actionName: 'GENERATOR_TTS_LOAD_MODEL'
22
+ }
23
+
24
+ /* Generate audio */
25
+ export type GeneratorTTSActionGenerate = ActionWithParams & {
26
+ __actionName: 'GENERATOR_TTS_GENERATE'
27
+ params?: Array<{
28
+ input: 'text'
29
+ value?: string | DataLink | EventProperty
30
+ mapping?: string
31
+ }>
32
+ }
33
+
34
+ /* Clean cache */
35
+ export type GeneratorTTSActionCleanCache = Action & {
36
+ __actionName: 'GENERATOR_TTS_CLEAN_CACHE'
37
+ }
38
+
39
+ /* Release context */
40
+ export type GeneratorTTSActionReleaseContext = Action & {
41
+ __actionName: 'GENERATOR_TTS_RELEASE_CONTEXT'
42
+ }
43
+
44
+ /* Cancel current generation and clear queue */
45
+ export type GeneratorTTSActionCancel = Action & {
46
+ __actionName: 'GENERATOR_TTS_CANCEL'
47
+ }
48
+
49
+ interface GeneratorTTSDef {
50
+ /*
51
+ Default property:
52
+ {
53
+ "model": "BricksDisplay/vits-eng",
54
+ "modelType": "auto",
55
+ "vocoderModel": "speecht5_hifigan",
56
+ "maxLength": 4096,
57
+ "temperature": 0.1,
58
+ "repetitionPenalty": 1.1,
59
+ "doSample": true,
60
+ "outputType": "play",
61
+ "cacheGenerated": true,
62
+ "speed": 1,
63
+ "autoInferEnable": false,
64
+ "softBreakRegex": "^[^\\r\\n\\t\\f\\v]*([\\r\\n]+|[。!?!?.]\\B)",
65
+ "hardBreakTime": 500,
66
+ "executionMode": "sequential"
67
+ }
68
+ */
69
+ property?: {
70
+ /* Initialize the TTS context on generator initialization */
71
+ init?: boolean | DataLink
72
+ /* TTS model
73
+ The mms-tts models are licensed under CC-BY-NC-4.0 */
74
+ model?: string | DataLink
75
+ /* Model type */
76
+ modelType?: string | DataLink
77
+ /* Quantize type */
78
+ quantizeType?:
79
+ | 'auto'
80
+ | 'none'
81
+ | 'fp16'
82
+ | 'q8'
83
+ | 'int8'
84
+ | 'uint8'
85
+ | 'q4'
86
+ | 'bnb4'
87
+ | 'q4f16'
88
+ | DataLink
89
+ /* Vocoder model for SpeechT5 */
90
+ vocoderModel?: 'Custom' | 'speecht5_hifigan' | DataLink
91
+ /* Custom vocoder model
92
+ Choose model from https://huggingface.co/models?library=transformers.js&other=hifigan */
93
+ customVocoderModel?: string | DataLink
94
+ /* Speaker embedding, for SpeechT5 or StyleTTS (Kokoro) */
95
+ speakerEmbedUrl?: string | DataLink
96
+ /* Hash of `speakerEmbedUrl` */
97
+ speakerEmbedHash?: string | DataLink
98
+ /* Hash type of `speakerEmbedUrl` */
99
+ speakerEmbedHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
100
+ /* Speaker config, for OuteTTS model */
101
+ speakerConfig?: {} | DataLink
102
+ /* Audio token generation max length */
103
+ maxLength?: number | DataLink
104
+ /* Audio token generation temperature */
105
+ temperature?: number | DataLink
106
+ /* Audio token generation repetition penalty */
107
+ repetitionPenalty?: number | DataLink
108
+ /* Use greedy sampling for audio token generation */
109
+ doSample?: boolean | DataLink
110
+ /* Output mode */
111
+ outputType?: 'play' | 'file' | DataLink
112
+ /* Enable cache for generated audio */
113
+ cacheGenerated?: boolean | DataLink
114
+ /* Speed of the generated audio, for StyleTTS (Kokoro) */
115
+ speed?: number | DataLink
116
+ /* Text to generate */
117
+ prompt?: string | DataLink
118
+ /* Auto inference when prompt changes */
119
+ autoInferEnable?: boolean | DataLink
120
+ /* Segmentation rule for auto inference */
121
+ softBreakRegex?: string | DataLink
122
+ /* Time to force inference when softBreakRegex is not satisfied */
123
+ hardBreakTime?: number | DataLink
124
+ /* Executor candidates, descending order of priority
125
+ Default will be xnnpack, wasm, cpu */
126
+ executors?:
127
+ | Array<'qnn' | 'dml' | 'nnapi' | 'xnnpack' | 'coreml' | 'cpu' | 'wasm' | 'webgpu' | DataLink>
128
+ | DataLink
129
+ /* Execution mode
130
+ Usually when the model has many branches, setting this option to `parallel` will give you better performance. */
131
+ executionMode?: 'sequential' | 'parallel' | DataLink
132
+ /* QNN backend */
133
+ qnnBackend?: 'HTP' | 'HTA' | 'DSP' | 'GPU' | 'CPU' | DataLink
134
+ /* Enable FP16 for QNN HTP */
135
+ qnnHtpEnableFp16?: boolean | DataLink
136
+ /* Enable QNN debug */
137
+ qnnEnableDebug?: boolean | DataLink
138
+ }
139
+ events?: {
140
+ /* Event triggered when state change */
141
+ onContextStateChange?: Array<
142
+ EventAction<string & keyof TemplateEventPropsMap['Tts']['onContextStateChange']>
143
+ >
144
+ /* Event triggered when error occurs */
145
+ onError?: Array<EventAction<string & keyof TemplateEventPropsMap['Tts']['onError']>>
146
+ }
147
+ outlets?: {
148
+ /* Context state */
149
+ contextState?: () => Data<string>
150
+ /* Generated audio file */
151
+ generatedAudio?: () => Data<string>
152
+ /* Generated audio file is playing */
153
+ generatedAudioPlaying?: () => Data<boolean>
154
+ }
155
+ }
156
+
157
+ /* Local Text-to-Speech (TTS) inference based on ONNX Runtime and [transformers.js](https://huggingface.co/docs/transformers.js)
158
+ You can use any converted model on HuggingFace. */
159
+ export type GeneratorTTS = Generator &
160
+ GeneratorTTSDef & {
161
+ templateKey: 'GENERATOR_TTS'
162
+ switches?: Array<
163
+ SwitchDef &
164
+ GeneratorTTSDef & {
165
+ conds?: Array<{
166
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
167
+ cond:
168
+ | SwitchCondInnerStateCurrentCanvas
169
+ | SwitchCondData
170
+ | {
171
+ __typename: 'SwitchCondInnerStateOutlet'
172
+ outlet: 'contextState' | 'generatedAudio' | 'generatedAudioPlaying'
173
+ value: any
174
+ }
175
+ }>
176
+ }
177
+ >
178
+ }
@@ -0,0 +1,121 @@
1
+ /* Auto generated by build script
2
+ *
3
+ * Generate speech from text using OpenAI's Text-to-Speech API
4
+ */
5
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
6
+ import type { Data, DataLink } from '../data'
7
+ import type {
8
+ Brick,
9
+ Generator,
10
+ EventAction,
11
+ ActionWithDataParams,
12
+ ActionWithParams,
13
+ Action,
14
+ EventProperty,
15
+ } from '../common'
16
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
17
+
18
+ /* Generate audio */
19
+ export type GeneratorOpenAiTTSActionGenerate = ActionWithParams & {
20
+ __actionName: 'GENERATOR_OPENAI_TTS_GENERATE'
21
+ params?: Array<{
22
+ input: 'text'
23
+ value?: string | DataLink | EventProperty
24
+ mapping?: string
25
+ }>
26
+ }
27
+
28
+ /* Clean cache */
29
+ export type GeneratorOpenAiTTSActionCleanCache = Action & {
30
+ __actionName: 'GENERATOR_OPENAI_TTS_CLEAN_CACHE'
31
+ }
32
+
33
+ /* Cancel current generation and clear queue */
34
+ export type GeneratorOpenAiTTSActionCancel = Action & {
35
+ __actionName: 'GENERATOR_OPENAI_TTS_CANCEL'
36
+ }
37
+
38
+ interface GeneratorOpenAiTTSDef {
39
+ /*
40
+ Default property:
41
+ {
42
+ "apiEndpoint": "https://api.openai.com/v1",
43
+ "model": "tts-1",
44
+ "voice": "alloy",
45
+ "speed": 1,
46
+ "outputType": "play",
47
+ "playbackVolume": 100,
48
+ "cacheGenerated": true,
49
+ "autoInferEnable": false,
50
+ "softBreakRegex": "^[^\\r\\n\\t\\f\\v]*([\\r\\n]+|[。!?!?.]\\B)",
51
+ "hardBreakTime": 500
52
+ }
53
+ */
54
+ property?: {
55
+ /* API endpoint URL */
56
+ apiEndpoint?: string | DataLink
57
+ /* OpenAI API Key */
58
+ apiKey?: string | DataLink
59
+ /* OpenAI TTS model */
60
+ model?: string | DataLink
61
+ /* Voice to use
62
+ Select voice from https://openai.fm , default alloy */
63
+ voice?: string | DataLink
64
+ /* Additional instructions for the speech generation */
65
+ instructions?: string | DataLink
66
+ /* Speed of the generated audio */
67
+ speed?: number | DataLink
68
+ /* Output mode */
69
+ outputType?: 'play' | 'file' | DataLink
70
+ /* Playback volume (0 - 100) */
71
+ playbackVolume?: number | DataLink
72
+ /* Enable cache for generated audio */
73
+ cacheGenerated?: boolean | DataLink
74
+ /* Text to generate */
75
+ prompt?: string | DataLink
76
+ /* Auto inference when prompt changes */
77
+ autoInferEnable?: boolean | DataLink
78
+ /* Segmentation rule for auto inference */
79
+ softBreakRegex?: string | DataLink
80
+ /* Time to force inference when softBreakRegex is not satisfied */
81
+ hardBreakTime?: number | DataLink
82
+ }
83
+ events?: {
84
+ /* Event triggered when state change */
85
+ onContextStateChange?: Array<
86
+ EventAction<string & keyof TemplateEventPropsMap['OpenaiTts']['onContextStateChange']>
87
+ >
88
+ /* Event triggered when error occurs */
89
+ onError?: Array<EventAction<string & keyof TemplateEventPropsMap['OpenaiTts']['onError']>>
90
+ }
91
+ outlets?: {
92
+ /* Context state */
93
+ contextState?: () => Data<string>
94
+ /* Generated audio file */
95
+ generatedAudio?: () => Data<string>
96
+ /* Generated audio file is playing */
97
+ generatedAudioPlaying?: () => Data<boolean>
98
+ }
99
+ }
100
+
101
+ /* Generate speech from text using OpenAI's Text-to-Speech API */
102
+ export type GeneratorOpenAiTTS = Generator &
103
+ GeneratorOpenAiTTSDef & {
104
+ templateKey: 'GENERATOR_OPENAI_TTS'
105
+ switches?: Array<
106
+ SwitchDef &
107
+ GeneratorOpenAiTTSDef & {
108
+ conds?: Array<{
109
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
110
+ cond:
111
+ | SwitchCondInnerStateCurrentCanvas
112
+ | SwitchCondData
113
+ | {
114
+ __typename: 'SwitchCondInnerStateOutlet'
115
+ outlet: 'contextState' | 'generatedAudio' | 'generatedAudioPlaying'
116
+ value: any
117
+ }
118
+ }>
119
+ }
120
+ >
121
+ }