TM Teachable Machine

TurboWarp extension · user guide

Turn movement into project input.

The extension connects a Teachable Machine Pose, Image, or Audio model to TurboWarp. Your camera frame or microphone audio becomes label probabilities that scripts can read as labels, scores, and Boolean conditions.

Camera previewLIVE
INPUT
↓
PROBABILITIES
Current label
jump0.91

Kamishibai DSL 4.0 bundle

Open the Teachable Machine manual from the combined palette

Click the documentation button immediately below the Teachable Machine member heading. The bundled blocks retain the model URL, recognition, preview, label, score, threshold, and lifecycle behavior described here. The TurboWarp Teachable Machine 3.5.1 package line keeps the public lifecycle opcodes startRecognition, stopRecognition, and isRecognizing, with no legacy aliases. Configurable SVG pose overlay blocks remain available in pose mode, while image mode uses label scoring without keypoints. Latest-needed model initialization and cancellation controls remain host APIs documented under Composition API.

Quick start

From model to motion in four steps

You need a published Teachable Machine Pose, Image, or Audio model, the matching camera or microphone permission, and network access. Load the downloaded tm.js from the custom extension dialog’s Files tab with Run without sandbox enabled, then place these blocks in order.

1

Train and publish

In Teachable Machine, give each class a useful name such as jump, card, or clap. Export the model and copy its share URL.

2

Set the model URL

Paste the model folder URL. A missing trailing slash is added automatically.

3

Start recognition

Allow camera or microphone access. The extension starts the required input and loads the model automatically if needed.

4

Use the result

Read the top label, test one class, or use a confidence value to control your project.

when green flag clicked
set model URL tohttps://teachablemachine.withgoogle.com/models/…/
start recognition
forever
if label is jump with confidence at least0.75

How it works

One input, several useful answers

While recognition is running, the extension repeatedly samples the selected camera or microphone input, runs the model in the browser, and stores a probability for every class in your model.

current label is the class with the highest probability. confidence is that class’s score, rounded to two decimal places. confidence of [NAME] reads one named class.

The preview sits on the stage

The preview is a camera canvas placed over the TurboWarp stage. It does not become a sprite and does not change model input when hidden. It is mirrored by default, and can switch between mirrored and unmirrored while the camera is running without changing recognition input.

Version 1.11.0 overlays the 17 recognized PoseNet joints and 12 standard bone connections as SVG by default. Blocks control visibility, each joint's color, opacity, and radius, shared bone color, opacity, and width, the minimum confidence, and independent confidence scaling for those visual properties.

The extension requests a normal Canvas2D context for its owned camera canvas. Physical-camera measurements of the 320x240, one-draw/one-read path did not show a repeatable end-to-end benefit from willReadFrequently; the hint helped a different read-heavy condition with four or more reads per draw, but could make video drawing more expensive. Chrome may therefore emit its Canvas2D readback warning during CPU inference. Other TurboWarp canvases are unchanged, and hosts do not need a global Canvas or Console patch.

camera
top-lefttop-rightbottom-leftbottom-rightcenterfull-stage

Start and stop are explicit

  • start camera opens the camera and displays the preview.
  • start recognition starts the required input and loads the model when necessary.
  • stop recognition clears live results, stops audio listening, and leaves the camera available.
  • stop camera stops recognition, releases media tracks, and removes the preview.
  • hide camera preview only changes what is shown; recognition can continue.

Composition hosts

Prepare only the model the story still needs

The composition API lets an application host cancel obsolete model demand while camera startup continues independently. The first inference waits for both the active input and one registered model.

Independent work and synchronization

SHA checks for separate PoseNet files run in parallel. Shared descriptor verification overlaps classifier loading, but unverified bytes never reach TensorFlow. Camera getUserMedia() and video.play() may run alongside the complete model path.

Latest-needed wins

Create the composition with modelInitializationPolicy: 'latest-needed' and pass an AbortSignal to registerPoseModel(). At most one heavy request is active and one newest request is pending. A cancelled model is never published to the registry.

Choosing a result

React now—or smooth motion over time

Default builds expose immediate probabilities. Builds that enable the optional temporalPoseScoring feature also expose accumulated scores for steadier decisions.

Default

Current confidence

Best for quick gestures. The answer follows every frame, so it reacts fast but may flicker near a decision boundary.

confidence per framethreshold

Use label is [NAME] with confidence at least [THRESHOLD]?. Thresholds are clamped to 0–1; 0.75 is a practical starting point.

Optional feature

Accumulated score

Best for sustained poses. Evidence is added over elapsed time while older evidence decays, reducing one-frame changes.

accumulated scorethreshold
previous × decayseconds + probability × accumulation × seconds

The reporter returns an empty label until the best positive score reaches the threshold. Hidden-tab time is excluded. Stopping recognition or resetting clears all accumulated scores.

Block guide

Pick the block for the job

Reporter values are empty or zero before the first usable recognition result and after recognition stops. Boolean status blocks are useful when coordinating startup.

Model setup

Configure and check the Teachable Machine model.

  • set model URL to [URL] changes the model and clears the previously loaded one.
  • load model fetches model.json and metadata.json.
  • model is loaded? reports readiness.
  • Teachable Machine version reports the extension build.

Compute backend

Choose how much of the machine recognition may use.

  • set compute mode to [MODE] · auto (default), webgpu, webgl, wasm, or cpu
  • compute mode reports what the project asked for.
  • active compute backend reports what the browser actually gave.

auto tries WebGPU, WebGL, WASM, and CPU in that order and keeps the first one that really computes. A named mode is a preference: when the browser cannot provide it the same order takes over, and last error explains the substitution. Change the mode before loading a model—switching releases a model loaded from a URL so it can be rebuilt on the new backend.

Camera and preview

Control capture separately from recognition.

  • start camera · stop camera · camera is running?
  • refresh camera list detects available video inputs.
  • set camera to [CAMERA] · default, front, back, or a detected device
  • camera count · camera device ID · camera device name
  • show camera preview · hide camera preview
  • camera preview is visible?
  • set camera preview opacity to [OPACITY] clamps opacity to 0–1.
  • set camera preview position to [POSITION]
  • set camera preview to [MIRRORING] · mirrored (default) or unmirrored
  • camera preview mirroring reports the current setting.
  • set pose overlay [VISIBILITY] · pose overlay is visible?
  • set [PART] joint color [COLOR] opacity [OPACITY] radius [RADIUS]
  • set pose bone color [COLOR] opacity [OPACITY] width [WIDTH]
  • set pose overlay minimum confidence to [CONFIDENCE]
  • set pose [PROPERTY] confidence scaling [STATE]

Camera labels may appear only after permission is granted. Device IDs are browser- and machine-specific. Switching a running camera preserves the model, recognition state, and preview settings; a failed switch attempts to restore the previous camera.

When TurboWarp-Camera-Source is loaded, this extension leases the camera it shares under the pose role, so one device serves recognition and anything else reading frames. stop camera then releases the lease without stopping tracks other consumers are reading. Camera Source is optional: without it the extension opens and stops its own camera as before, and nothing in a project changes.

Recognition and results

Start the loop, read scores, and make decisions.

  • start recognition · stop recognition · recognition is running?
  • current label · confidence · confidence of [NAME]
  • label is [NAME]? uses a fixed 0.75 threshold.
  • label is [NAME] with confidence at least [THRESHOLD]?

Timing and errors

Measure startup and show useful failure details.

  • camera startup time (ms)
  • model load time (ms)
  • first recognition time (ms)
  • last error keeps the latest runtime error message.

Accumulated-pose blocks

Live confidence flickers frame to frame near a decision boundary; these blocks combine evidence over time so a brief misrecognition cannot flip a decision. They are in the palette by default (temporalPoseScoring): set accumulated pose accumulation [ACCUMULATION] decay [DECAY], set accumulated pose threshold [THRESHOLD], reset accumulated pose scores, accumulated pose, accumulated score, and accumulated score of [NAME]. Decay is the fraction retained after one second (0–1), and a decay change takes effect the next time recognition starts.

Troubleshooting

When the result is not what you expect

Check last error first. Most setup failures come from permissions, an incorrect model URL, blocked network requests, or loading the extension in the sandbox. A sandboxed load is silent in the editor: the dialog keeps waiting and only the browser console shows TM must run without the extension sandbox. Load the file from the Files tab, never from the URL tab.

start camera also needs the page to have been interacted with once. Browsers refuse video.play() without user activation, reported as NotAllowedError: play() failed because the user didn’t interact with the document first. Clicking the green flag counts, so an ordinary project is fine; a project that starts on its own must wait for a button press.

The camera does not start

Allow camera permission for the TurboWarp page and make sure another application is not exclusively using the camera. The page must run in a secure context (HTTPS or localhost). Then run start camera again.

The model does not load

Use the published Teachable Machine model folder URL—not a link to the editor or an individual JSON file. The extension appends model.json and metadata.json to that URL. Confirm that the network allows jsDelivr and Teachable Machine model hosting.

The label is unstable

Add more varied training examples, keep the whole body visible, improve lighting, and test a threshold such as 0.75. If your build exposes accumulated-pose blocks, use them for a pose that must be held for a short time.

The preview is missing but recognition works

Run show camera preview, set opacity above zero, and choose a supported position. Packaged projects with a modified stage DOM may not support preview attachment; last error explains stage-detection failures.

Teachable Machine: complete block reference

All 48 blocks are documented below, including compatibility blocks and blocks available through optional features. Select a block to read its behavior, arguments, default values, and menu choices. Each block has a permanent link.

Teachable Machine version

Returns the extension version.

Block type: REPORTER. Opcode: versionReporter. Permanent link

This block has no arguments.

set recognition mode to [MODE]

Selects whether the current Teachable Machine model recognizes poses, images, or audio.

Block type: COMMAND. Opcode: setRecognitionMode. Permanent link

ArgumentTypeDefault valueMenu choices
MODESTRINGpose

Fixed input controls and value preservation

recognition mode

Returns the current recognition mode.

Block type: REPORTER. Opcode: recognitionModeReporter. Permanent link

This block has no arguments.

set compute mode to [MODE]

Selects the TensorFlow.js compute backend. "auto" negotiates WebGPU, WebGL, WASM, and CPU in that order and falls back automatically when a backend is unusable. Changing the mode releases a model that was loaded from a URL so it can be reloaded on the new backend.

Block type: COMMAND. Opcode: setComputeMode. Permanent link

ArgumentTypeDefault valueMenu choices
MODESTRINGauto

Fixed input controls and value preservation

compute mode

Returns the requested compute mode.

Block type: REPORTER. Opcode: computeModeReporter. Permanent link

This block has no arguments.

active compute backend

Returns the TensorFlow.js backend recognition is actually running on, which can differ from the requested mode when the browser could not provide it.

Block type: REPORTER. Opcode: computeBackendReporter. Permanent link

This block has no arguments.

set model URL to [URL]

Sets the Teachable Machine model URL.

Block type: COMMAND. Opcode: setModelURL. Permanent link

ArgumentTypeDefault valueMenu choices
URLSTRINGhttps://teachablemachine.withgoogle.com/models/XXXX/

start camera

Starts the camera and attaches the preview.

Block type: COMMAND. Opcode: startCamera. Permanent link

This block has no arguments.

stop camera

Stops the camera and recognition loop.

Block type: COMMAND. Opcode: stopCamera. Permanent link

This block has no arguments.

camera is running?

Reports whether the camera is running.

Block type: BOOLEAN. Opcode: isCameraRunning. Permanent link

This block has no arguments.

refresh camera list

Refreshes the list of available video input devices.

Block type: COMMAND. Opcode: refreshCameraList. Permanent link

This block has no arguments.

set camera to [CAMERA]

Selects the default, front, back, or a detected camera and switches a running camera.

Block type: COMMAND. Opcode: setCameraSelection. Permanent link

ArgumentTypeDefault valueMenu choices
CAMERASTRINGdefault

camera count

Returns the number of video input devices found by the latest refresh.

Block type: REPORTER. Opcode: cameraCountReporter. Permanent link

This block has no arguments.

camera device ID

Returns the active camera device ID when available.

Block type: REPORTER. Opcode: cameraDeviceIdReporter. Permanent link

This block has no arguments.

camera device name

Returns the active camera device name when available.

Block type: REPORTER. Opcode: cameraDeviceNameReporter. Permanent link

This block has no arguments.

show camera preview

Shows the camera preview.

Block type: COMMAND. Opcode: showPreview. Permanent link

This block has no arguments.

hide camera preview

Hides the camera preview.

Block type: COMMAND. Opcode: hidePreview. Permanent link

This block has no arguments.

camera preview is visible?

Reports whether the preview is configured as visible.

Block type: BOOLEAN. Opcode: isPreviewVisible. Permanent link

This block has no arguments.

set camera preview opacity to [OPACITY]

Sets preview opacity from 0 to 1.

Block type: COMMAND. Opcode: setPreviewOpacity. Permanent link

ArgumentTypeDefault valueMenu choices
OPACITYNUMBER0.6

Fixed input controls and value preservation

set camera preview position to [POSITION]

Sets the preview position on the stage.

Block type: COMMAND. Opcode: setPreviewPosition. Permanent link

ArgumentTypeDefault valueMenu choices
POSITIONSTRINGbottom-right

Fixed input controls and value preservation

set camera preview to [MIRRORING]

Sets whether the preview is mirrored without changing the recognition input.

Block type: COMMAND. Opcode: setPreviewMirroring. Permanent link

ArgumentTypeDefault valueMenu choices
MIRRORINGSTRINGmirrored

Fixed input controls and value preservation

camera preview mirroring

Returns mirrored or unmirrored for the current preview setting.

Block type: REPORTER. Opcode: previewMirroringReporter. Permanent link

This block has no arguments.

set pose overlay [VISIBILITY]

Shows or hides the SVG pose overlay without stopping recognition.

Block type: COMMAND. Opcode: setPoseOverlayVisibility. Permanent link

Available when the optional poseOverlay feature is enabled.

ArgumentTypeDefault valueMenu choices
VISIBILITYSTRINGon

Fixed input controls and value preservation

pose overlay is visible?

Reports whether the SVG pose overlay is configured as visible.

Block type: BOOLEAN. Opcode: isPoseOverlayVisible. Permanent link

Available when the optional poseOverlay feature is enabled.

This block has no arguments.

set [PART] joint color [COLOR] opacity [OPACITY] radius [RADIUS]

Sets the SVG circle style for one PoseNet joint.

Block type: COMMAND. Opcode: setPoseJointStyle. Permanent link

Available when the optional poseOverlay feature is enabled.

ArgumentTypeDefault valueMenu choices
PARTSTRINGnose
COLORSTRING#00e5ff
OPACITYNUMBER1
RADIUSNUMBER4

Fixed input controls and value preservation

set pose bone color [COLOR] opacity [OPACITY] width [WIDTH]

Sets the color, opacity, and line width for all SVG pose bones.

Block type: COMMAND. Opcode: setPoseBoneStyle. Permanent link

Available when the optional poseOverlay feature is enabled.

ArgumentTypeDefault valueMenu choices
COLORSTRING#00e5ff
OPACITYNUMBER0.9
WIDTHNUMBER3

Fixed input controls and value preservation

set pose overlay minimum confidence to [CONFIDENCE]

Hides joints and bones whose keypoint confidence is below the given value.

Block type: COMMAND. Opcode: setPoseOverlayMinimumConfidence. Permanent link

Available when the optional poseOverlay feature is enabled.

ArgumentTypeDefault valueMenu choices
CONFIDENCENUMBER0.5

Fixed input controls and value preservation

set pose [PROPERTY] confidence scaling [STATE]

Scales the selected SVG style property from zero to its configured value using keypoint confidence.

Block type: COMMAND. Opcode: setPoseConfidenceScaling. Permanent link

Available when the optional poseOverlay feature is enabled.

ArgumentTypeDefault valueMenu choices
PROPERTYSTRINGjoint-opacity
STATESTRINGoff

Fixed input controls and value preservation

load model

Loads the configured Teachable Machine model.

Block type: COMMAND. Opcode: loadModel. Permanent link

This block has no arguments.

model is loaded?

Reports whether the model is loaded.

Block type: BOOLEAN. Opcode: isModelLoaded. Permanent link

This block has no arguments.

start recognition

Starts recognition.

Block type: COMMAND. Opcode: startRecognition. Permanent link

This block has no arguments.

stop recognition

Stops recognition.

Block type: COMMAND. Opcode: stopRecognition. Permanent link

This block has no arguments.

recognition is running?

Reports whether recognition is running.

Block type: BOOLEAN. Opcode: isRecognizing. Permanent link

This block has no arguments.

current label

Returns the highest-scoring label.

Block type: REPORTER. Opcode: currentPoseReporter. Permanent link

This block has no arguments.

confidence

Returns the confidence of the current label.

Block type: REPORTER. Opcode: scoreReporter. Permanent link

This block has no arguments.

confidence of [NAME]

Returns the confidence for a named label.

Block type: REPORTER. Opcode: poseScoreReporter. Permanent link

ArgumentTypeDefault valueMenu choices
NAMESTRINGjump

set accumulated pose accumulation [ACCUMULATION] decay [DECAY]

Sets the accumulation rate per second and the decay retained per second; decay changes apply to the next recognition session.

Block type: COMMAND. Opcode: setAccumulatedPoseParameters. Permanent link

Available when the optional temporalPoseScoring feature is enabled.

ArgumentTypeDefault valueMenu choices
ACCUMULATIONNUMBER1
DECAYNUMBER0.9

Fixed input controls and value preservation

set accumulated pose threshold [THRESHOLD]

Sets the minimum accumulated score required to report a pose; values below the threshold report an empty string.

Block type: COMMAND. Opcode: setAccumulatedPoseThreshold. Permanent link

Available when the optional temporalPoseScoring feature is enabled.

ArgumentTypeDefault valueMenu choices
THRESHOLDNUMBER0

Fixed input controls and value preservation

reset accumulated pose scores

Clears all accumulated pose scores.

Block type: COMMAND. Opcode: resetAccumulatedPose. Permanent link

Available when the optional temporalPoseScoring feature is enabled.

This block has no arguments.

accumulated pose

Returns the pose label whose accumulated score is highest and meets the threshold, or an empty string otherwise.

Block type: REPORTER. Opcode: accumulatedPoseReporter. Permanent link

Available when the optional temporalPoseScoring feature is enabled.

This block has no arguments.

accumulated score

Returns the highest accumulated pose score without rounding.

Block type: REPORTER. Opcode: accumulatedScoreReporter. Permanent link

Available when the optional temporalPoseScoring feature is enabled.

This block has no arguments.

accumulated score of [NAME]

Returns the accumulated score for a named pose without rounding.

Block type: REPORTER. Opcode: accumulatedPoseScoreReporter. Permanent link

Available when the optional temporalPoseScoring feature is enabled.

ArgumentTypeDefault valueMenu choices
NAMESTRINGjump

label is [NAME]?

Reports whether the named label has at least 0.75 confidence.

Block type: BOOLEAN. Opcode: isPose. Permanent link

ArgumentTypeDefault valueMenu choices
NAMESTRINGjump

label is [NAME] with confidence at least [THRESHOLD]?

Reports whether the named label meets the given threshold.

Block type: BOOLEAN. Opcode: isPoseWithThreshold. Permanent link

ArgumentTypeDefault valueMenu choices
NAMESTRINGjump
THRESHOLDNUMBER0.75

Fixed input controls and value preservation

camera startup time (ms)

Returns camera startup time in milliseconds.

Block type: REPORTER. Opcode: cameraMsReporter. Permanent link

This block has no arguments.

model load time (ms)

Returns model load time in milliseconds.

Block type: REPORTER. Opcode: modelLoadMsReporter. Permanent link

This block has no arguments.

first recognition time (ms)

Returns first recognition time in milliseconds.

Block type: REPORTER. Opcode: firstRecognitionMsReporter. Permanent link

This block has no arguments.

last error

Returns the latest recorded error message.

Block type: REPORTER. Opcode: lastErrorReporter. Permanent link

This block has no arguments.

Repository guide and examples

Optional fixed-input editor

Fixed menus and finite numeric inputs preserve existing raw values unless edited. Connected reporters remain read only and are never evaluated. Failed saves retain drafts; cancel, dispose and scope changes discard them. Existing runtime clamps and serializers remain unchanged. The fixed editor is OFF by default; enable blockEditorDialogs and blockEditorFixedInputs at startup.

固定入力の契約・保持規則・切戻し