@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,94 @@
1
+ /* Auto generated by build script
2
+ *
3
+ * Play sound, see supported formats at https://developer.android.com/guide/topics/media/media-formats
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
+ /* Start playing sound */
19
+ export type GeneratorSoundPlayerActionPlay = Action & {
20
+ __actionName: 'GENERATOR_SOUND_PLAYER_PLAY'
21
+ }
22
+
23
+ /* Pause playing sound */
24
+ export type GeneratorSoundPlayerActionPause = Action & {
25
+ __actionName: 'GENERATOR_SOUND_PLAYER_PAUSE'
26
+ }
27
+
28
+ /* Resume playing sound from pause */
29
+ export type GeneratorSoundPlayerActionResume = Action & {
30
+ __actionName: 'GENERATOR_SOUND_PLAYER_RESUME'
31
+ }
32
+
33
+ /* Stop playing sound */
34
+ export type GeneratorSoundPlayerActionRelease = Action & {
35
+ __actionName: 'GENERATOR_SOUND_PLAYER_RELEASE'
36
+ }
37
+
38
+ interface GeneratorSoundPlayerDef {
39
+ /*
40
+ Default property:
41
+ {
42
+ "loop": false,
43
+ "volume": 100
44
+ }
45
+ */
46
+ property?: {
47
+ /* Sound file path */
48
+ filePath?: string | DataLink
49
+ /* MD5 */
50
+ md5?: string | DataLink
51
+ /* Repeat playback */
52
+ loop?: boolean | DataLink
53
+ /* Sound volume (0 - 100) */
54
+ volume?: number | DataLink
55
+ }
56
+ events?: {
57
+ /* Sound file loaded successfully */
58
+ onLoad?: Array<EventAction>
59
+ /* Sound file load error */
60
+ onLoadError?: Array<
61
+ EventAction<string & keyof TemplateEventPropsMap['SoundPlayer']['onLoadError']>
62
+ >
63
+ /* Sound playback complete */
64
+ onPlay?: Array<EventAction>
65
+ /* Sound file playback end */
66
+ onEnd?: Array<EventAction>
67
+ }
68
+ outlets?: {
69
+ /* Whether the sound is playing */
70
+ isPlaying?: () => Data<any>
71
+ }
72
+ }
73
+
74
+ /* Play sound, see supported formats at https://developer.android.com/guide/topics/media/media-formats */
75
+ export type GeneratorSoundPlayer = Generator &
76
+ GeneratorSoundPlayerDef & {
77
+ templateKey: 'GENERATOR_SOUND_PLAYER'
78
+ switches?: Array<
79
+ SwitchDef &
80
+ GeneratorSoundPlayerDef & {
81
+ conds?: Array<{
82
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
83
+ cond:
84
+ | SwitchCondInnerStateCurrentCanvas
85
+ | SwitchCondData
86
+ | {
87
+ __typename: 'SwitchCondInnerStateOutlet'
88
+ outlet: 'isPlaying'
89
+ value: any
90
+ }
91
+ }>
92
+ }
93
+ >
94
+ }
@@ -0,0 +1,130 @@
1
+ /* Auto generated by build script
2
+ *
3
+ * Record audio (Microphone)
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
+ /* Start record */
19
+ export type GeneratorSoundRecorderActionStart = Action & {
20
+ __actionName: 'GENERATOR_SOUND_RECORDER_START'
21
+ }
22
+
23
+ /* Pause record */
24
+ export type GeneratorSoundRecorderActionPause = Action & {
25
+ __actionName: 'GENERATOR_SOUND_RECORDER_PAUSE'
26
+ }
27
+
28
+ /* Resume record */
29
+ export type GeneratorSoundRecorderActionResume = Action & {
30
+ __actionName: 'GENERATOR_SOUND_RECORDER_RESUME'
31
+ }
32
+
33
+ /* Stop record */
34
+ export type GeneratorSoundRecorderActionStop = Action & {
35
+ __actionName: 'GENERATOR_SOUND_RECORDER_STOP'
36
+ }
37
+
38
+ /* List available microphone devices (Web / Desktop only) */
39
+ export type GeneratorSoundRecorderActionListDevices = Action & {
40
+ __actionName: 'GENERATOR_SOUND_RECORDER_LIST_DEVICES'
41
+ }
42
+
43
+ interface GeneratorSoundRecorderDef {
44
+ /*
45
+ Default property:
46
+ {
47
+ "init": false,
48
+ "sampleRate": 32000,
49
+ "bitDepth": "16bit",
50
+ "channels": "stereo",
51
+ "fileRetainTime": 10000,
52
+ "autoCuttingEnable": false,
53
+ "autoCuttingTimeLimit": 0,
54
+ "autoCuttingVocalFreqMin": 75,
55
+ "autoCuttingVocalFreqMax": 900,
56
+ "autoCuttingFreqClarity": 0.5,
57
+ "autoCuttingSpeakSpacing": 0.5
58
+ }
59
+ */
60
+ property?: {
61
+ /* Start record on init (Need user trigger on Web) */
62
+ init?: boolean | DataLink
63
+ /* Specifies the device ID to use for audio input.
64
+ Web / Desktop: device ID string from enumerateDevices
65
+ Android: audio source name - DEFAULT, MIC, VOICE_UPLINK, VOICE_DOWNLINK, VOICE_CALL, CAMCORDER, VOICE_RECOGNITION, VOICE_COMMUNICATION, UNPROCESSED */
66
+ deviceId?: string | DataLink
67
+ /* Record sample rate */
68
+ sampleRate?: number | DataLink
69
+ /* PCM bit depth */
70
+ bitDepth?: '8bit' | '16bit' | DataLink
71
+ /* Audio channels */
72
+ channels?: 'mono' | 'stereo' | DataLink
73
+ /* Record file retain time, avoid memory exhausted */
74
+ fileRetainTime?: number | DataLink
75
+ /* Enable record auto cutting */
76
+ autoCuttingEnable?: boolean | DataLink
77
+ /* Fragment time limit */
78
+ autoCuttingTimeLimit?: number | DataLink
79
+ /* Minimal vocal frequency of cutting fragments */
80
+ autoCuttingVocalFreqMin?: number | DataLink
81
+ /* Maximal vocal frequency of cutting fragments */
82
+ autoCuttingVocalFreqMax?: number | DataLink
83
+ /* Minimum frequency clarity threshold on speaking (0 ~ 1) */
84
+ autoCuttingFreqClarity?: number | DataLink
85
+ /* Minimum volume threshold on speaking */
86
+ autoCuttingVolumeThreshold?: number | DataLink
87
+ /* Speak spacing of cutting fragments */
88
+ autoCuttingSpeakSpacing?: number | DataLink
89
+ }
90
+ events?: {
91
+ /* Event for chunk data (Base64 encoded PCM) */
92
+ chunk?: Array<EventAction<string & keyof TemplateEventPropsMap['SoundRecorder']['chunk']>>
93
+ /* Event for recorded file */
94
+ recorded?: Array<EventAction<string & keyof TemplateEventPropsMap['SoundRecorder']['recorded']>>
95
+ }
96
+ outlets?: {
97
+ /* Is recording */
98
+ isRecording?: () => Data<boolean>
99
+ /* Recorded file path */
100
+ recordedPath?: () => Data<string>
101
+ /* Current auto-cutting detected volume */
102
+ volume?: () => Data<number>
103
+ /* Error message */
104
+ errorMessage?: () => Data<string>
105
+ /* Available microphone devices (Web / Desktop only) */
106
+ devices?: () => Data<Array<any>>
107
+ }
108
+ }
109
+
110
+ /* Record audio (Microphone) */
111
+ export type GeneratorSoundRecorder = Generator &
112
+ GeneratorSoundRecorderDef & {
113
+ templateKey: 'GENERATOR_SOUND_RECORDER'
114
+ switches?: Array<
115
+ SwitchDef &
116
+ GeneratorSoundRecorderDef & {
117
+ conds?: Array<{
118
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
119
+ cond:
120
+ | SwitchCondInnerStateCurrentCanvas
121
+ | SwitchCondData
122
+ | {
123
+ __typename: 'SwitchCondInnerStateOutlet'
124
+ outlet: 'isRecording' | 'recordedPath' | 'volume' | 'errorMessage' | 'devices'
125
+ value: any
126
+ }
127
+ }>
128
+ }
129
+ >
130
+ }
@@ -0,0 +1,415 @@
1
+ /* Auto generated by build script
2
+ *
3
+ * Local Speech-to-Text (STT) inference based on GGML and [whisper.cpp](https://github.com/ggerganov/whisper.cpp)
4
+ *
5
+ * ## Notice
6
+ * - iOS: Supported GPU acceleration, recommended use M1+ / A17+ chip device
7
+ * - macOS: Supported GPU acceleration, recommended use M1+ chip device
8
+ * - Android: Currently not supported GPU acceleration (Coming soon), recommended use Android 13+ system
9
+ * - Linux / Windows: Supported GPU acceleration, you can choose `vulkan` or `cuda` backend in Accel Variant property
10
+ */
11
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
12
+ import type { Data, DataLink } from '../data'
13
+ import type {
14
+ Brick,
15
+ Generator,
16
+ EventAction,
17
+ ActionWithDataParams,
18
+ ActionWithParams,
19
+ Action,
20
+ EventProperty,
21
+ } from '../common'
22
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
23
+
24
+ /* Load the model */
25
+ export type GeneratorSpeechInferenceActionLoadModel = Action & {
26
+ __actionName: 'GENERATOR_SPEECH_INFERENCE_LOAD_MODEL'
27
+ }
28
+
29
+ /* Transcribe audio file. You can provide `File URL` property, if not provided, it will use the default `File URL` */
30
+ export type GeneratorSpeechInferenceActionTranscribeFile = ActionWithParams & {
31
+ __actionName: 'GENERATOR_SPEECH_INFERENCE_TRANSCRIBE_FILE'
32
+ params?: Array<
33
+ | {
34
+ input: 'fileUrl'
35
+ value?: string | DataLink | EventProperty
36
+ mapping?: string
37
+ }
38
+ | {
39
+ input: 'prompt'
40
+ value?: string | DataLink | EventProperty
41
+ mapping?: string
42
+ }
43
+ | {
44
+ input: 'beamSize'
45
+ value?: number | DataLink | EventProperty
46
+ mapping?: string
47
+ }
48
+ | {
49
+ input: 'language'
50
+ value?: string | DataLink | EventProperty
51
+ mapping?: string
52
+ }
53
+ | {
54
+ input: 'translate'
55
+ value?: boolean | DataLink | EventProperty
56
+ mapping?: string
57
+ }
58
+ >
59
+ }
60
+
61
+ /* Transcribe audio data. Currently only support base64 encoded audio data (16-bit PCM, mono, 16kHz) */
62
+ export type GeneratorSpeechInferenceActionTranscribeData = ActionWithParams & {
63
+ __actionName: 'GENERATOR_SPEECH_INFERENCE_TRANSCRIBE_DATA'
64
+ params?: Array<
65
+ | {
66
+ input: 'data'
67
+ value?: any | EventProperty
68
+ mapping?: string
69
+ }
70
+ | {
71
+ input: 'prompt'
72
+ value?: string | DataLink | EventProperty
73
+ mapping?: string
74
+ }
75
+ | {
76
+ input: 'beamSize'
77
+ value?: number | DataLink | EventProperty
78
+ mapping?: string
79
+ }
80
+ | {
81
+ input: 'language'
82
+ value?: string | DataLink | EventProperty
83
+ mapping?: string
84
+ }
85
+ | {
86
+ input: 'translate'
87
+ value?: boolean | DataLink | EventProperty
88
+ mapping?: string
89
+ }
90
+ >
91
+ }
92
+
93
+ /* Stop current transcription */
94
+ export type GeneratorSpeechInferenceActionTranscribeStop = Action & {
95
+ __actionName: 'GENERATOR_SPEECH_INFERENCE_TRANSCRIBE_STOP'
96
+ }
97
+
98
+ /* Clear downloaded files (model, audio) & current jobs */
99
+ export type GeneratorSpeechInferenceActionClearDownload = Action & {
100
+ __actionName: 'GENERATOR_SPEECH_INFERENCE_CLEAR_DOWNLOAD'
101
+ }
102
+
103
+ /* Release context */
104
+ export type GeneratorSpeechInferenceActionReleaseContext = Action & {
105
+ __actionName: 'GENERATOR_SPEECH_INFERENCE_RELEASE_CONTEXT'
106
+ }
107
+
108
+ interface GeneratorSpeechInferenceDef {
109
+ /*
110
+ Default property:
111
+ {
112
+ "init": false,
113
+ "accelVariant": "default",
114
+ "modelName": "base-q8_0",
115
+ "modelUseCoreML": false,
116
+ "modelUseGPU": true,
117
+ "modelUseFlashAttn": false,
118
+ "inferLanguage": "Auto"
119
+ }
120
+ */
121
+ property?: {
122
+ /* Initialize the Whisper context on generator initialization
123
+ Please note that it will take some RAM depending on the model size */
124
+ init?: boolean | DataLink
125
+ /* Accelerator variant (Only for desktop)
126
+ `default` - CPU / Metal (macOS)
127
+ `vulkan` - Use Vulkan
128
+ `cuda` - Use CUDA */
129
+ accelVariant?: 'default' | 'vulkan' | 'cuda' | DataLink
130
+ /* Use model name, the model download progress will be done in preload stage or the generator initialization stage.
131
+ We used `ggml` format model, please refer to https://huggingface.co/BricksDisplay/whisper-ggml
132
+ You can also choose `custom` option and set `Model URL` and `Model MD5` to use your own model */
133
+ modelName?:
134
+ | 'custom'
135
+ | 'tiny'
136
+ | 'tiny-q5_1'
137
+ | 'tiny-q8_0'
138
+ | 'tiny.en'
139
+ | 'tiny.en-q5_1'
140
+ | 'tiny.en-q8_0'
141
+ | 'base'
142
+ | 'base-q5_1'
143
+ | 'base-q8_0'
144
+ | 'base.en'
145
+ | 'base.en-q5_1'
146
+ | 'base.en-q8_0'
147
+ | 'small'
148
+ | 'small-q5_1'
149
+ | 'small-q8_0'
150
+ | 'small.en'
151
+ | 'small.en-q5_1'
152
+ | 'small.en-q8_0'
153
+ | 'medium'
154
+ | 'medium-q5_0'
155
+ | 'medium-q8_0'
156
+ | 'medium.en'
157
+ | 'medium.en-q5_0'
158
+ | 'medium.en-q8_0'
159
+ | 'large-v1'
160
+ | 'large-v2'
161
+ | 'large-v2-q5_0'
162
+ | 'large-v2-q8_0'
163
+ | 'large-v3'
164
+ | 'large-v3-q5_0'
165
+ | 'large-v3-turbo'
166
+ | 'large-v3-turbo-q5_0'
167
+ | 'large-v3-turbo-q8_0'
168
+ | 'small.en-tdrz'
169
+ | 'small.en-tdrz-q5_1'
170
+ | 'small.en-tdrz-q8_0'
171
+ | 'distil-small.en'
172
+ | 'distil-small.en-q5_1'
173
+ | 'distil-small.en-q8_0'
174
+ | 'distil-medium.en'
175
+ | 'distil-medium.en-q5_0'
176
+ | 'distil-medium.en-q8_0'
177
+ | 'distil-large-v3'
178
+ | 'distil-large-v3-q5_0'
179
+ | 'distil-large-v3-q8_0'
180
+ | DataLink
181
+ /* The URL or path of model
182
+ We used `ggml` format model, please refer to https://github.com/ggerganov/whisper.cpp/tree/master/models */
183
+ modelUrl?: string | DataLink
184
+ /* Hash type of model */
185
+ modelHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
186
+ /* Hash of model */
187
+ modelHash?: string | DataLink
188
+ /* [Unstable] iOS: Use CoreML model for inference */
189
+ modelUseCoreML?: boolean | DataLink
190
+ /* Use GPU Acceleration for inference. Currently iOS only, if it's enabled, Core ML option will be ignored. */
191
+ modelUseGPU?: boolean | DataLink
192
+ /* Use Flash Attention for inference (Recommended with GPU enabled) */
193
+ modelUseFlashAttn?: boolean | DataLink
194
+ /* The language of the file to be inferred */
195
+ inferLanguage?:
196
+ | 'Auto'
197
+ | 'English (en)'
198
+ | 'Chinese (zh)'
199
+ | 'German (de)'
200
+ | 'Spanish (es)'
201
+ | 'Russian (ru)'
202
+ | 'Korean (ko)'
203
+ | 'French (fr)'
204
+ | 'Japanese (ja)'
205
+ | 'Portuguese (pt)'
206
+ | 'Turkish (tr)'
207
+ | 'Polish (pl)'
208
+ | 'Catalan (ca)'
209
+ | 'Dutch (nl)'
210
+ | 'Arabic (ar)'
211
+ | 'Swedish (sv)'
212
+ | 'Italian (it)'
213
+ | 'Indonesian (id)'
214
+ | 'Hindi (hi)'
215
+ | 'Finnish (fi)'
216
+ | 'Vietnamese (vi)'
217
+ | 'Hebrew (he)'
218
+ | 'Ukrainian (uk)'
219
+ | 'Greek (el)'
220
+ | 'Malay (ms)'
221
+ | 'Czech (cs)'
222
+ | 'Romanian (ro)'
223
+ | 'Danish (da)'
224
+ | 'Hungarian (hu)'
225
+ | 'Tamil (ta)'
226
+ | 'Norwegian (no)'
227
+ | 'Thai (th)'
228
+ | 'Urdu (ur)'
229
+ | 'Croatian (hr)'
230
+ | 'Bulgarian (bg)'
231
+ | 'Lithuanian (lt)'
232
+ | 'Latin (la)'
233
+ | 'Maori (mi)'
234
+ | 'Malayalam (ml)'
235
+ | 'Welsh (cy)'
236
+ | 'Slovak (sk)'
237
+ | 'Telugu (te)'
238
+ | 'Persian (fa)'
239
+ | 'Latvian (lv)'
240
+ | 'Bengali (bn)'
241
+ | 'Serbian (sr)'
242
+ | 'Azerbaijani (az)'
243
+ | 'Slovenian (sl)'
244
+ | 'Kannada (kn)'
245
+ | 'Estonian (et)'
246
+ | 'Macedonian (mk)'
247
+ | 'Breton (br)'
248
+ | 'Basque (eu)'
249
+ | 'Icelandic (is)'
250
+ | 'Armenian (hy)'
251
+ | 'Nepali (ne)'
252
+ | 'Mongolian (mn)'
253
+ | 'Bosnian (bs)'
254
+ | 'Kazakh (kk)'
255
+ | 'Albanian (sq)'
256
+ | 'Swahili (sw)'
257
+ | 'Galician (gl)'
258
+ | 'Marathi (mr)'
259
+ | 'Punjabi (pa)'
260
+ | 'Sinhala (si)'
261
+ | 'Khmer (km)'
262
+ | 'Shona (sn)'
263
+ | 'Yoruba (yo)'
264
+ | 'Somali (so)'
265
+ | 'Afrikaans (af)'
266
+ | 'Occitan (oc)'
267
+ | 'Georgian (ka)'
268
+ | 'Belarusian (be)'
269
+ | 'Tajik (tg)'
270
+ | 'Sindhi (sd)'
271
+ | 'Gujarati (gu)'
272
+ | 'Amharic (am)'
273
+ | 'Yiddish (yi)'
274
+ | 'Lao (lo)'
275
+ | 'Uzbek (uz)'
276
+ | 'Faroese (fo)'
277
+ | 'Haitian Creole (ht)'
278
+ | 'Pashto (ps)'
279
+ | 'Turkmen (tk)'
280
+ | 'Nynorsk (nn)'
281
+ | 'Maltese (mt)'
282
+ | 'Sanskrit (sa)'
283
+ | 'Luxembourgish (lb)'
284
+ | 'Myanmar (my)'
285
+ | 'Tibetan (bo)'
286
+ | 'Tagalog (tl)'
287
+ | 'Malagasy (mg)'
288
+ | 'Assamese (as)'
289
+ | 'Tatar (tt)'
290
+ | 'Hawaiian (haw)'
291
+ | 'Lingala (ln)'
292
+ | 'Hausa (ha)'
293
+ | 'Bashkir (ba)'
294
+ | 'Javanese (jw)'
295
+ | 'Sundanese (su)'
296
+ | DataLink
297
+ /* Initial prompt text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. */
298
+ inferPrompt?: string | DataLink
299
+ /* Beam size to use for beam search (enables beam search if set) */
300
+ inferBeamSize?: number | DataLink
301
+ /* Translate the result to English */
302
+ inferTranslate?: boolean | DataLink
303
+ /* Max threads to use for inference */
304
+ inferMaxThreads?: number | DataLink
305
+ /* Output token-level timestamps in details outlet */
306
+ inferTokenTimestamps?: boolean | DataLink
307
+ /* Speaker diarization (Please use small.en-tdrz model) */
308
+ inferTdrz?: boolean | DataLink
309
+ /* Maximum segment length in characters */
310
+ inferMaxLength?: number | DataLink
311
+ /* Audio time offset in milliseconds */
312
+ inferOffset?: number | DataLink
313
+ /* Audio duration of audio to process in milliseconds */
314
+ inferDuration?: number | DataLink
315
+ /* The file URL or path to be inferred.
316
+ It only supported `wav` format with 16kHz sample rate & single (mono) channel */
317
+ inferFileUrl?: string | DataLink
318
+ /* MD5 of file to be inferred */
319
+ inferFileMd5?: string | DataLink
320
+ /* Buttress connection settings for remote inference */
321
+ buttressConnectionSettings?:
322
+ | DataLink
323
+ | {
324
+ enabled?: boolean | DataLink
325
+ url?: string | DataLink
326
+ fallbackType?: 'use-local' | 'no-op' | DataLink
327
+ strategy?: 'prefer-local' | 'prefer-buttress' | 'prefer-best' | DataLink
328
+ }
329
+ }
330
+ events?: {
331
+ /* Event triggered when context state changes */
332
+ onContextStateChange?: Array<
333
+ EventAction<string & keyof TemplateEventPropsMap['SpeechInference']['onContextStateChange']>
334
+ >
335
+ /* Event triggered when error occurs */
336
+ onError?: Array<EventAction<string & keyof TemplateEventPropsMap['SpeechInference']['onError']>>
337
+ /* Event triggered when got transcribe result */
338
+ onTranscribed?: Array<
339
+ EventAction<string & keyof TemplateEventPropsMap['SpeechInference']['onTranscribed']>
340
+ >
341
+ /* Event triggered when transcribe realtime done */
342
+ onRealtimeStop?: Array<EventAction>
343
+ }
344
+ outlets?: {
345
+ /* Context state */
346
+ contextState?: () => Data<string>
347
+ /* Context details */
348
+ contextDetails?: () => Data<{
349
+ state?: string
350
+ contextId?: string
351
+ gpu?: string
352
+ reasonNoGPU?: string
353
+ [key: string]: any
354
+ }>
355
+ /* Is transcribing */
356
+ isTranscribing?: () => Data<boolean>
357
+ /* Progress of transcribe audio (0-100) */
358
+ transcribeProgress?: () => Data<number>
359
+ /* Inference result */
360
+ transcribeResult?: () => Data<string>
361
+ /* Inference result details */
362
+ transcribeDetails?: () => Data<{
363
+ result?: string
364
+ segments?: Array<{
365
+ start?: number
366
+ end?: number
367
+ confidence?: number
368
+ t0?: number
369
+ t1?: number
370
+ [key: string]: any
371
+ }>
372
+ time?: number
373
+ startTime?: number
374
+ endTime?: number
375
+ [key: string]: any
376
+ }>
377
+ /* Recorded audio file path of transcribe realtime (if `Save Audio` is enabled) */
378
+ recordedPath?: () => Data<string>
379
+ }
380
+ }
381
+
382
+ /* Local Speech-to-Text (STT) inference based on GGML and [whisper.cpp](https://github.com/ggerganov/whisper.cpp)
383
+
384
+ ## Notice
385
+ - iOS: Supported GPU acceleration, recommended use M1+ / A17+ chip device
386
+ - macOS: Supported GPU acceleration, recommended use M1+ chip device
387
+ - Android: Currently not supported GPU acceleration (Coming soon), recommended use Android 13+ system
388
+ - Linux / Windows: Supported GPU acceleration, you can choose `vulkan` or `cuda` backend in Accel Variant property */
389
+ export type GeneratorSpeechInference = Generator &
390
+ GeneratorSpeechInferenceDef & {
391
+ templateKey: 'GENERATOR_SPEECH_INFERENCE'
392
+ switches?: Array<
393
+ SwitchDef &
394
+ GeneratorSpeechInferenceDef & {
395
+ conds?: Array<{
396
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
397
+ cond:
398
+ | SwitchCondInnerStateCurrentCanvas
399
+ | SwitchCondData
400
+ | {
401
+ __typename: 'SwitchCondInnerStateOutlet'
402
+ outlet:
403
+ | 'contextState'
404
+ | 'contextDetails'
405
+ | 'isTranscribing'
406
+ | 'transcribeProgress'
407
+ | 'transcribeResult'
408
+ | 'transcribeDetails'
409
+ | 'recordedPath'
410
+ value: any
411
+ }
412
+ }>
413
+ }
414
+ >
415
+ }