@fugood/bricks-project 2.22.0-beta.27 → 2.22.0-beta.28

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 (78) hide show
  1. package/package.json +2 -2
  2. package/types/animation.ts +1 -0
  3. package/types/brick-base.ts +77 -0
  4. package/types/bricks/3DViewer.ts +200 -0
  5. package/types/bricks/Camera.ts +195 -0
  6. package/types/bricks/Chart.ts +362 -0
  7. package/types/bricks/GenerativeMedia.ts +237 -0
  8. package/types/bricks/Icon.ts +90 -0
  9. package/types/bricks/Image.ts +101 -0
  10. package/types/bricks/Items.ts +461 -0
  11. package/types/bricks/Lottie.ts +156 -0
  12. package/types/bricks/Qrcode.ts +109 -0
  13. package/types/bricks/Rect.ts +107 -0
  14. package/types/bricks/RichText.ts +120 -0
  15. package/types/bricks/Rive.ts +209 -0
  16. package/types/bricks/Slideshow.ts +155 -0
  17. package/types/bricks/Svg.ts +91 -0
  18. package/types/bricks/Text.ts +140 -0
  19. package/types/bricks/TextInput.ts +231 -0
  20. package/types/bricks/Video.ts +167 -0
  21. package/types/bricks/VideoStreaming.ts +104 -0
  22. package/types/bricks/WebRTCStream.ts +60 -0
  23. package/types/bricks/WebView.ts +157 -0
  24. package/types/bricks/index.ts +20 -0
  25. package/types/generators/AlarmClock.ts +102 -0
  26. package/types/generators/Assistant.ts +546 -0
  27. package/types/generators/BleCentral.ts +225 -0
  28. package/types/generators/BlePeripheral.ts +202 -0
  29. package/types/generators/CanvasMap.ts +57 -0
  30. package/types/generators/CastlesPay.ts +77 -0
  31. package/types/generators/DataBank.ts +123 -0
  32. package/types/generators/File.ts +351 -0
  33. package/types/generators/GraphQL.ts +124 -0
  34. package/types/generators/HTTP.ts +117 -0
  35. package/types/generators/HTTPServer.ts +156 -0
  36. package/types/generators/Information.ts +97 -0
  37. package/types/generators/Intent.ts +107 -0
  38. package/types/generators/Iterator.ts +95 -0
  39. package/types/generators/Keyboard.ts +85 -0
  40. package/types/generators/LlmAnthropicCompat.ts +188 -0
  41. package/types/generators/LlmGgml.ts +719 -0
  42. package/types/generators/LlmOnnx.ts +184 -0
  43. package/types/generators/LlmOpenAiCompat.ts +206 -0
  44. package/types/generators/LlmQualcommAiEngine.ts +213 -0
  45. package/types/generators/MCP.ts +294 -0
  46. package/types/generators/MCPServer.ts +245 -0
  47. package/types/generators/MQTTBroker.ts +121 -0
  48. package/types/generators/MediaFlow.ts +142 -0
  49. package/types/generators/MqttClient.ts +129 -0
  50. package/types/generators/Question.ts +395 -0
  51. package/types/generators/RealtimeTranscription.ts +172 -0
  52. package/types/generators/RerankerGgml.ts +153 -0
  53. package/types/generators/SerialPort.ts +141 -0
  54. package/types/generators/SoundPlayer.ts +86 -0
  55. package/types/generators/SoundRecorder.ts +113 -0
  56. package/types/generators/SpeechToTextGgml.ts +462 -0
  57. package/types/generators/SpeechToTextOnnx.ts +227 -0
  58. package/types/generators/SpeechToTextPlatform.ts +75 -0
  59. package/types/generators/Sqlite.ts +118 -0
  60. package/types/generators/Step.ts +101 -0
  61. package/types/generators/TCP.ts +120 -0
  62. package/types/generators/TCPServer.ts +137 -0
  63. package/types/generators/TapToPayOnIPhone.ts +175 -0
  64. package/types/generators/TextToSpeechGgml.ts +182 -0
  65. package/types/generators/TextToSpeechOnnx.ts +169 -0
  66. package/types/generators/TextToSpeechOpenAiLike.ts +113 -0
  67. package/types/generators/ThermalPrinter.ts +185 -0
  68. package/types/generators/Tick.ts +75 -0
  69. package/types/generators/UDP.ts +109 -0
  70. package/types/generators/VadGgml.ts +211 -0
  71. package/types/generators/VectorStore.ts +223 -0
  72. package/types/generators/Watchdog.ts +96 -0
  73. package/types/generators/WebCrawler.ts +97 -0
  74. package/types/generators/WebRTC.ts +165 -0
  75. package/types/generators/WebSocket.ts +142 -0
  76. package/types/generators/index.ts +51 -0
  77. package/types/bricks.ts +0 -3269
  78. package/types/generators.ts +0 -8632
@@ -0,0 +1,175 @@
1
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
2
+ import type { Data, DataLink } from '../data'
3
+ import type {
4
+ Generator,
5
+ EventAction,
6
+ ActionWithDataParams,
7
+ ActionWithParams,
8
+ Action,
9
+ EventProperty,
10
+ } from '../common'
11
+
12
+ /* Init */
13
+ export type GeneratorTapPayT2PActionSetup = Action & {
14
+ __actionName: 'GENERATOR_TAPPAY_T2P_IOS_SETUP'
15
+ }
16
+
17
+ /* <No doc yet> */
18
+ export type GeneratorTapPayT2PActionFetchBindingList = Action & {
19
+ __actionName: 'GENERATOR_TAPPAY_T2P_IOS_FETCH_BINDING_LIST'
20
+ }
21
+
22
+ /* <No doc yet> */
23
+ export type GeneratorTapPayT2PActionBind = ActionWithParams & {
24
+ __actionName: 'GENERATOR_TAPPAY_T2P_IOS_BIND'
25
+ params?: Array<
26
+ | {
27
+ input: 'bindId'
28
+ value?: number | DataLink | EventProperty
29
+ mapping?: string
30
+ }
31
+ | {
32
+ input: 'bindDescription'
33
+ value?: string | DataLink | EventProperty
34
+ mapping?: string
35
+ }
36
+ >
37
+ }
38
+
39
+ /* <No doc yet> */
40
+ export type GeneratorTapPayT2PActionBindDelete = Action & {
41
+ __actionName: 'GENERATOR_TAPPAY_T2P_IOS_BIND_DELETE'
42
+ }
43
+
44
+ /* <No doc yet> */
45
+ export type GeneratorTapPayT2PActionConfigureReader = Action & {
46
+ __actionName: 'GENERATOR_TAPPAY_T2P_IOS_CONFIGURE_READER'
47
+ }
48
+
49
+ /* <No doc yet> */
50
+ export type GeneratorTapPayT2PActionReadCardAndAuthorization = ActionWithParams & {
51
+ __actionName: 'GENERATOR_TAPPAY_T2P_IOS_READ_CARD_AND_AUTHORIZATION'
52
+ params?: Array<
53
+ | {
54
+ input: 'amount'
55
+ value?: number | DataLink | EventProperty
56
+ mapping?: string
57
+ }
58
+ | {
59
+ input: 'orderNumber'
60
+ value?: string | DataLink | EventProperty
61
+ mapping?: string
62
+ }
63
+ | {
64
+ input: 'bankTransactionId'
65
+ value?: string | DataLink | EventProperty
66
+ mapping?: string
67
+ }
68
+ >
69
+ }
70
+
71
+ /* <No doc yet> */
72
+ export type GeneratorTapPayT2PActionGetReceipt = ActionWithParams & {
73
+ __actionName: 'GENERATOR_TAPPAY_T2P_IOS_GET_RECEIPT'
74
+ params?: Array<
75
+ | {
76
+ input: 'receiptIdentifier'
77
+ value?: string | DataLink | EventProperty
78
+ mapping?: string
79
+ }
80
+ | {
81
+ input: 'type'
82
+ value?: 'html' | 'pkpass' | DataLink | EventProperty
83
+ mapping?: string
84
+ }
85
+ | {
86
+ input: 'email'
87
+ value?: string | DataLink | EventProperty
88
+ mapping?: string
89
+ }
90
+ >
91
+ }
92
+
93
+ interface GeneratorTapPayT2PDef {
94
+ /*
95
+ Default property:
96
+ {
97
+ "page": 0,
98
+ "countPerPage": 10
99
+ }
100
+ */
101
+ property?: {
102
+ /* Initializtion */
103
+ init?: boolean | DataLink
104
+ /* App Key */
105
+ appKey?: string | DataLink
106
+ /* Enviroment */
107
+ enviroment?: 'sandbox' | 'production' | DataLink
108
+ /* Partner Account */
109
+ partnerAccount?: string | DataLink
110
+ /* Page */
111
+ page?: number | DataLink
112
+ /* Count per page */
113
+ countPerPage?: number | DataLink
114
+ /* Acquirer Merchant ID */
115
+ acquirerMerchantId?: string | DataLink
116
+ /* Acquirer Terminal ID */
117
+ acquirerTerminalId?: string | DataLink
118
+ /* Bind ID */
119
+ bindId?: number | DataLink
120
+ /* Bind Description */
121
+ bindDescription?: string | DataLink
122
+ }
123
+ events?: {
124
+ /* <No doc yet> */
125
+ readerStartConfiguring?: Array<EventAction>
126
+ /* <No doc yet> */
127
+ readerEndConfiguring?: Array<EventAction>
128
+ /* <No doc yet> */
129
+ readerEventDidUpdated?: Array<EventAction>
130
+ /* <No doc yet> */
131
+ onError?: Array<EventAction>
132
+ }
133
+ outlets?: {
134
+ /* undefined */
135
+ error?: () => Data
136
+ /* undefined */
137
+ isReaderBinded?: () => Data
138
+ /* undefined */
139
+ isReaderReady?: () => Data
140
+ /* undefined */
141
+ bindingList?: () => Data
142
+ /* undefined */
143
+ lastTransactionResult?: () => Data
144
+ /* undefined */
145
+ getReceiptResult?: () => Data
146
+ }
147
+ }
148
+
149
+ /* [UNSTABLE] Tap to Pay on iPhone (iOS only) */
150
+ export type GeneratorTapPayT2P = Generator &
151
+ GeneratorTapPayT2PDef & {
152
+ templateKey: 'GENERATOR_TAPPAY_T2P_IOS'
153
+ switches: Array<
154
+ SwitchDef &
155
+ GeneratorTapPayT2PDef & {
156
+ conds?: Array<{
157
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
158
+ cond:
159
+ | SwitchCondInnerStateCurrentCanvas
160
+ | SwitchCondData
161
+ | {
162
+ __typename: 'SwitchCondInnerStateOutlet'
163
+ outlet:
164
+ | 'error'
165
+ | 'isReaderBinded'
166
+ | 'isReaderReady'
167
+ | 'bindingList'
168
+ | 'lastTransactionResult'
169
+ | 'getReceiptResult'
170
+ value: any
171
+ }
172
+ }>
173
+ }
174
+ >
175
+ }
@@ -0,0 +1,182 @@
1
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
2
+ import type { Data, DataLink } from '../data'
3
+ import type {
4
+ Generator,
5
+ EventAction,
6
+ ActionWithDataParams,
7
+ ActionWithParams,
8
+ Action,
9
+ EventProperty,
10
+ } from '../common'
11
+
12
+ /* Load the model */
13
+ export type GeneratorGGMLTTSActionLoadModel = Action & {
14
+ __actionName: 'GENERATOR_GGML_TTS_LOAD_MODEL'
15
+ }
16
+
17
+ /* Generate audio */
18
+ export type GeneratorGGMLTTSActionGenerate = ActionWithParams & {
19
+ __actionName: 'GENERATOR_GGML_TTS_GENERATE'
20
+ params?: Array<{
21
+ input: 'text'
22
+ value?: string | DataLink | EventProperty
23
+ mapping?: string
24
+ }>
25
+ }
26
+
27
+ /* Clean cache */
28
+ export type GeneratorGGMLTTSActionCleanCache = Action & {
29
+ __actionName: 'GENERATOR_GGML_TTS_CLEAN_CACHE'
30
+ }
31
+
32
+ /* Release context */
33
+ export type GeneratorGGMLTTSActionReleaseContext = Action & {
34
+ __actionName: 'GENERATOR_GGML_TTS_RELEASE_CONTEXT'
35
+ }
36
+
37
+ /* Cancel current generation and clear queue */
38
+ export type GeneratorGGMLTTSActionCancel = Action & {
39
+ __actionName: 'GENERATOR_GGML_TTS_CANCEL'
40
+ }
41
+
42
+ interface GeneratorGGMLTTSDef {
43
+ /*
44
+ Default property:
45
+ {
46
+ "vocoderUrl": "https://huggingface.co/ggml-org/WavTokenizer/resolve/main/WavTokenizer-Large-75-F16.gguf",
47
+ "vocoderHashType": "sha256",
48
+ "vocoderHash": "2356baa8631cc2995ea3465196a017a2733600d849a91180c0f97fa7fb375bbe",
49
+ "vocoderBatchSize": 4096,
50
+ "outputType": "play",
51
+ "cacheGenerated": true,
52
+ "autoInferEnable": false,
53
+ "softBreakRegex": "^[^\\r\\n\\t\\f\\v]*([\\r\\n]+|[。!?!?.]\\B)",
54
+ "hardBreakTime": 500,
55
+ "completionTemperature": 0.1,
56
+ "completionRepetitionPenalty": 1.1,
57
+ "completionTopK": 40,
58
+ "completionTopP": 0.9,
59
+ "completionMinP": 0.05,
60
+ "useGuideToken": true,
61
+ "contextSize": 8192,
62
+ "batchSize": 8192,
63
+ "microBatchSize": 512,
64
+ "maxThreads": 2,
65
+ "accelVariant": "default",
66
+ "mainGpu": 0,
67
+ "gpuLayers": 0,
68
+ "useMlock": true,
69
+ "useMmap": true,
70
+ "useFlashAttn": "off"
71
+ }
72
+ */
73
+ property?: {
74
+ /* Initialize the TTS context on generator initialization */
75
+ init?: boolean | DataLink
76
+ /* The URL or path of model
77
+ We used GGUF format model, please refer to https://github.com/ggerganov/llama.cpp/tree/master#description */
78
+ modelUrl?: string | DataLink
79
+ /* Hash type of model */
80
+ modelHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
81
+ /* Hash of model */
82
+ modelHash?: string | DataLink
83
+ /* The URL or path of vocoder model */
84
+ vocoderUrl?: string | DataLink
85
+ /* Hash type of vocoder model */
86
+ vocoderHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
87
+ /* Hash of vocoder model */
88
+ vocoderHash?: string | DataLink
89
+ /* Batch size of vocoder model */
90
+ vocoderBatchSize?: number | DataLink
91
+ /* Output mode */
92
+ outputType?: 'play' | 'file' | DataLink
93
+ /* Enable cache for generated audio */
94
+ cacheGenerated?: boolean | DataLink
95
+ /* Text to generate */
96
+ prompt?: string | DataLink
97
+ /* Speaker JSON */
98
+ speaker?: {} | DataLink
99
+ /* Auto inference when prompt changes */
100
+ autoInferEnable?: boolean | DataLink
101
+ /* Segmentation rule for auto inference */
102
+ softBreakRegex?: string | DataLink
103
+ /* Time to force inference when softBreakRegex is not satisfied */
104
+ hardBreakTime?: number | DataLink
105
+ /* Temperature */
106
+ completionTemperature?: number | DataLink
107
+ /* Repetition Penalty */
108
+ completionRepetitionPenalty?: number | DataLink
109
+ /* Top K sampling */
110
+ completionTopK?: number | DataLink
111
+ /* Top P sampling */
112
+ completionTopP?: number | DataLink
113
+ /* Min P sampling */
114
+ completionMinP?: number | DataLink
115
+ /* Set the random number generator (RNG) seed (default: -1, -1 = random seed) */
116
+ completionSeed?: number | DataLink
117
+ /* Number of tokens to predict */
118
+ completionPredict?: number | DataLink
119
+ /* Enable guide token to help prevent hallucinations by forcing the TTS to use the correct words. */
120
+ useGuideToken?: boolean | DataLink
121
+ /* Context size, for OutTTS recommended 4096 ~ 8192 (Default to 4096) */
122
+ contextSize?: number | DataLink
123
+ /* Logical batch size for prompt processing */
124
+ batchSize?: number | DataLink
125
+ /* Physical batch size for prompt processing */
126
+ microBatchSize?: number | DataLink
127
+ /* Number of threads */
128
+ maxThreads?: number | DataLink
129
+ /* Accelerator variant (Only for desktop)
130
+ `default` - CPU / Metal (macOS)
131
+ `vulkan` - Use Vulkan
132
+ `cuda` - Use CUDA */
133
+ accelVariant?: 'default' | 'vulkan' | 'cuda' | DataLink
134
+ /* Main GPU index */
135
+ mainGpu?: number | DataLink
136
+ /* Number of GPU layers (NOTE: Currently not supported for Android) */
137
+ gpuLayers?: number | DataLink
138
+ /* Use memory lock */
139
+ useMlock?: boolean | DataLink
140
+ /* Use mmap */
141
+ useMmap?: boolean | DataLink
142
+ /* Use Flash Attention for inference (Recommended with GPU enabled) */
143
+ useFlashAttn?: 'auto' | 'on' | 'off' | DataLink
144
+ }
145
+ events?: {
146
+ /* Event triggered when state change */
147
+ onContextStateChange?: Array<EventAction>
148
+ /* Event triggered when error occurs */
149
+ onError?: Array<EventAction>
150
+ }
151
+ outlets?: {
152
+ /* Context state */
153
+ contextState?: () => Data
154
+ /* Generated audio file */
155
+ generatedAudio?: () => Data
156
+ /* Generated audio file is playing */
157
+ generatedAudioPlaying?: () => Data
158
+ }
159
+ }
160
+
161
+ /* Local Text-to-Speech (TTS) inference based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
162
+ You can use any converted model on HuggingFace. */
163
+ export type GeneratorGGMLTTS = Generator &
164
+ GeneratorGGMLTTSDef & {
165
+ templateKey: 'GENERATOR_GGML_TTS'
166
+ switches: Array<
167
+ SwitchDef &
168
+ GeneratorGGMLTTSDef & {
169
+ conds?: Array<{
170
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
171
+ cond:
172
+ | SwitchCondInnerStateCurrentCanvas
173
+ | SwitchCondData
174
+ | {
175
+ __typename: 'SwitchCondInnerStateOutlet'
176
+ outlet: 'contextState' | 'generatedAudio' | 'generatedAudioPlaying'
177
+ value: any
178
+ }
179
+ }>
180
+ }
181
+ >
182
+ }
@@ -0,0 +1,169 @@
1
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
2
+ import type { Data, DataLink } from '../data'
3
+ import type {
4
+ Generator,
5
+ EventAction,
6
+ ActionWithDataParams,
7
+ ActionWithParams,
8
+ Action,
9
+ EventProperty,
10
+ } from '../common'
11
+
12
+ /* Load the model */
13
+ export type GeneratorTTSActionLoadModel = Action & {
14
+ __actionName: 'GENERATOR_TTS_LOAD_MODEL'
15
+ }
16
+
17
+ /* Generate audio */
18
+ export type GeneratorTTSActionGenerate = ActionWithParams & {
19
+ __actionName: 'GENERATOR_TTS_GENERATE'
20
+ params?: Array<{
21
+ input: 'text'
22
+ value?: string | DataLink | EventProperty
23
+ mapping?: string
24
+ }>
25
+ }
26
+
27
+ /* Clean cache */
28
+ export type GeneratorTTSActionCleanCache = Action & {
29
+ __actionName: 'GENERATOR_TTS_CLEAN_CACHE'
30
+ }
31
+
32
+ /* Release context */
33
+ export type GeneratorTTSActionReleaseContext = Action & {
34
+ __actionName: 'GENERATOR_TTS_RELEASE_CONTEXT'
35
+ }
36
+
37
+ /* Cancel current generation and clear queue */
38
+ export type GeneratorTTSActionCancel = Action & {
39
+ __actionName: 'GENERATOR_TTS_CANCEL'
40
+ }
41
+
42
+ interface GeneratorTTSDef {
43
+ /*
44
+ Default property:
45
+ {
46
+ "model": "BricksDisplay/vits-eng",
47
+ "modelType": "auto",
48
+ "vocoderModel": "speecht5_hifigan",
49
+ "maxLength": 4096,
50
+ "temperature": 0.1,
51
+ "repetitionPenalty": 1.1,
52
+ "doSample": true,
53
+ "outputType": "play",
54
+ "cacheGenerated": true,
55
+ "speed": 1,
56
+ "autoInferEnable": false,
57
+ "softBreakRegex": "^[^\\r\\n\\t\\f\\v]*([\\r\\n]+|[。!?!?.]\\B)",
58
+ "hardBreakTime": 500,
59
+ "executionMode": "sequential"
60
+ }
61
+ */
62
+ property?: {
63
+ /* Initialize the TTS context on generator initialization */
64
+ init?: boolean | DataLink
65
+ /* TTS model
66
+ The mms-tts models are licensed under CC-BY-NC-4.0 */
67
+ model?: string | DataLink
68
+ /* Model type */
69
+ modelType?: string | DataLink
70
+ /* Quantize type */
71
+ quantizeType?:
72
+ | 'auto'
73
+ | 'none'
74
+ | 'fp16'
75
+ | 'q8'
76
+ | 'int8'
77
+ | 'uint8'
78
+ | 'q4'
79
+ | 'bnb4'
80
+ | 'q4f16'
81
+ | DataLink
82
+ /* Vocoder model for SpeechT5 */
83
+ vocoderModel?: 'Custom' | 'speecht5_hifigan' | DataLink
84
+ /* Custom vocoder model
85
+ Choose model from https://huggingface.co/models?library=transformers.js&other=hifigan */
86
+ customVocoderModel?: string | DataLink
87
+ /* Speaker embedding, for SpeechT5 or StyleTTS (Kokoro) */
88
+ speakerEmbedUrl?: string | DataLink
89
+ /* Hash of `speakerEmbedUrl` */
90
+ speakerEmbedHash?: string | DataLink
91
+ /* Hash type of `speakerEmbedUrl` */
92
+ speakerEmbedHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
93
+ /* Speaker config, for OuteTTS model */
94
+ speakerConfig?: {} | DataLink
95
+ /* Audio token generation max length */
96
+ maxLength?: number | DataLink
97
+ /* Audio token generation temperature */
98
+ temperature?: number | DataLink
99
+ /* Audio token generation repetition penalty */
100
+ repetitionPenalty?: number | DataLink
101
+ /* Use greedy sampling for audio token generation */
102
+ doSample?: boolean | DataLink
103
+ /* Output mode */
104
+ outputType?: 'play' | 'file' | DataLink
105
+ /* Enable cache for generated audio */
106
+ cacheGenerated?: boolean | DataLink
107
+ /* Speed of the generated audio, for StyleTTS (Kokoro) */
108
+ speed?: number | DataLink
109
+ /* Text to generate */
110
+ prompt?: string | DataLink
111
+ /* Auto inference when prompt changes */
112
+ autoInferEnable?: boolean | DataLink
113
+ /* Segmentation rule for auto inference */
114
+ softBreakRegex?: string | DataLink
115
+ /* Time to force inference when softBreakRegex is not satisfied */
116
+ hardBreakTime?: number | DataLink
117
+ /* Executor candidates, descending order of priority
118
+ Default will be xnnpack, wasm, cpu */
119
+ executors?:
120
+ | Array<'qnn' | 'dml' | 'nnapi' | 'xnnpack' | 'coreml' | 'cpu' | 'wasm' | 'webgpu' | DataLink>
121
+ | DataLink
122
+ /* Execution mode
123
+ Usually when the model has many branches, setting this option to `parallel` will give you better performance. */
124
+ executionMode?: 'sequential' | 'parallel' | DataLink
125
+ /* QNN backend */
126
+ qnnBackend?: 'HTP' | 'HTA' | 'DSP' | 'GPU' | 'CPU' | DataLink
127
+ /* Enable FP16 for QNN HTP */
128
+ qnnHtpEnableFp16?: boolean | DataLink
129
+ /* Enable QNN debug */
130
+ qnnEnableDebug?: boolean | DataLink
131
+ }
132
+ events?: {
133
+ /* Event triggered when state change */
134
+ onContextStateChange?: Array<EventAction>
135
+ /* Event triggered when error occurs */
136
+ onError?: Array<EventAction>
137
+ }
138
+ outlets?: {
139
+ /* Context state */
140
+ contextState?: () => Data
141
+ /* Generated audio file */
142
+ generatedAudio?: () => Data
143
+ /* Generated audio file is playing */
144
+ generatedAudioPlaying?: () => Data
145
+ }
146
+ }
147
+
148
+ /* Local Text-to-Speech (TTS) inference based on ONNX Runtime and [transformers.js](https://huggingface.co/docs/transformers.js)
149
+ You can use any converted model on HuggingFace. */
150
+ export type GeneratorTTS = Generator &
151
+ GeneratorTTSDef & {
152
+ templateKey: 'GENERATOR_TTS'
153
+ switches: Array<
154
+ SwitchDef &
155
+ GeneratorTTSDef & {
156
+ conds?: Array<{
157
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
158
+ cond:
159
+ | SwitchCondInnerStateCurrentCanvas
160
+ | SwitchCondData
161
+ | {
162
+ __typename: 'SwitchCondInnerStateOutlet'
163
+ outlet: 'contextState' | 'generatedAudio' | 'generatedAudioPlaying'
164
+ value: any
165
+ }
166
+ }>
167
+ }
168
+ >
169
+ }
@@ -0,0 +1,113 @@
1
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
2
+ import type { Data, DataLink } from '../data'
3
+ import type {
4
+ Generator,
5
+ EventAction,
6
+ ActionWithDataParams,
7
+ ActionWithParams,
8
+ Action,
9
+ EventProperty,
10
+ } from '../common'
11
+
12
+ /* Generate audio */
13
+ export type GeneratorOpenAiTTSActionGenerate = ActionWithParams & {
14
+ __actionName: 'GENERATOR_OPENAI_TTS_GENERATE'
15
+ params?: Array<{
16
+ input: 'text'
17
+ value?: string | DataLink | EventProperty
18
+ mapping?: string
19
+ }>
20
+ }
21
+
22
+ /* Clean cache */
23
+ export type GeneratorOpenAiTTSActionCleanCache = Action & {
24
+ __actionName: 'GENERATOR_OPENAI_TTS_CLEAN_CACHE'
25
+ }
26
+
27
+ /* Cancel current generation and clear queue */
28
+ export type GeneratorOpenAiTTSActionCancel = Action & {
29
+ __actionName: 'GENERATOR_OPENAI_TTS_CANCEL'
30
+ }
31
+
32
+ interface GeneratorOpenAiTTSDef {
33
+ /*
34
+ Default property:
35
+ {
36
+ "apiEndpoint": "https://api.openai.com/v1",
37
+ "model": "tts-1",
38
+ "voice": "alloy",
39
+ "speed": 1,
40
+ "outputType": "play",
41
+ "playbackVolume": 100,
42
+ "cacheGenerated": true,
43
+ "autoInferEnable": false,
44
+ "softBreakRegex": "^[^\\r\\n\\t\\f\\v]*([\\r\\n]+|[。!?!?.]\\B)",
45
+ "hardBreakTime": 500
46
+ }
47
+ */
48
+ property?: {
49
+ /* API endpoint URL */
50
+ apiEndpoint?: string | DataLink
51
+ /* OpenAI API Key */
52
+ apiKey?: string | DataLink
53
+ /* OpenAI TTS model */
54
+ model?: string | DataLink
55
+ /* Voice to use
56
+ Select voice from https://openai.fm , default alloy */
57
+ voice?: string | DataLink
58
+ /* Additional instructions for the speech generation */
59
+ instructions?: string | DataLink
60
+ /* Speed of the generated audio */
61
+ speed?: number | DataLink
62
+ /* Output mode */
63
+ outputType?: 'play' | 'file' | DataLink
64
+ /* Playback volume (0 - 100) */
65
+ playbackVolume?: number | DataLink
66
+ /* Enable cache for generated audio */
67
+ cacheGenerated?: boolean | DataLink
68
+ /* Text to generate */
69
+ prompt?: string | DataLink
70
+ /* Auto inference when prompt changes */
71
+ autoInferEnable?: boolean | DataLink
72
+ /* Segmentation rule for auto inference */
73
+ softBreakRegex?: string | DataLink
74
+ /* Time to force inference when softBreakRegex is not satisfied */
75
+ hardBreakTime?: number | DataLink
76
+ }
77
+ events?: {
78
+ /* Event triggered when state change */
79
+ onContextStateChange?: Array<EventAction>
80
+ /* Event triggered when error occurs */
81
+ onError?: Array<EventAction>
82
+ }
83
+ outlets?: {
84
+ /* Context state */
85
+ contextState?: () => Data
86
+ /* Generated audio file */
87
+ generatedAudio?: () => Data
88
+ /* Generated audio file is playing */
89
+ generatedAudioPlaying?: () => Data
90
+ }
91
+ }
92
+
93
+ /* Generate speech from text using OpenAI's Text-to-Speech API */
94
+ export type GeneratorOpenAiTTS = Generator &
95
+ GeneratorOpenAiTTSDef & {
96
+ templateKey: 'GENERATOR_OPENAI_TTS'
97
+ switches: Array<
98
+ SwitchDef &
99
+ GeneratorOpenAiTTSDef & {
100
+ conds?: Array<{
101
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
102
+ cond:
103
+ | SwitchCondInnerStateCurrentCanvas
104
+ | SwitchCondData
105
+ | {
106
+ __typename: 'SwitchCondInnerStateOutlet'
107
+ outlet: 'contextState' | 'generatedAudio' | 'generatedAudioPlaying'
108
+ value: any
109
+ }
110
+ }>
111
+ }
112
+ >
113
+ }