This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@component | |
export class SpeechToText extends BaseScriptComponent { | |
private voiceMLModule: VoiceMLModule = require("LensStudio:VoiceMLModule"); | |
onAwake() { | |
let options = VoiceML.ListeningOptions.create(); | |
options.shouldReturnAsrTranscription = true; | |
options.shouldReturnInterimAsrTranscription = true; | |
this.voiceMLModule.onListeningEnabled.add(() => { | |
this.voiceMLModule.startListening(options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@component | |
export class AudioHelper extends BaseScriptComponent { | |
// Private property to hold a reference to the AudioComponent | |
private audioComponent: AudioComponent; | |
// Called when the script is initialized | |
onAwake() { | |
// Retrieve the AudioComponent attached to the same SceneObject | |
this.audioComponent = this.sceneObject.getComponent("AudioComponent"); | |
// Call the testSeek method to set up a test event |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@component | |
export class CameraCrop extends BaseScriptComponent { | |
@input | |
nonCropImage: Image; | |
@input | |
croppedImage: Image; | |
//Generate this through Asset Browser > Screen Crop Texture | |
@input | |
screenCropCameraTexture: Texture; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* PinholeCameraModel takes the camera intrinsic values from the device camera, | |
* and provides helper methods to convert between 2D and 3D coordinates. | |
*/ | |
export class PinholeCameraModel { | |
public readonly resolution: vec2; | |
public readonly focalLength: vec2; | |
public readonly principalPoint: vec2; | |
constructor(resolution: vec2, focalLength: vec2, principalPoint: vec2) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
OneEuroFilterQuat, | |
OneEuroFilterVec3, | |
} from "./SpectaclesInteractionKit/Utils/OneEuroFilter"; | |
const FILTER_CONFIG = { | |
frequency: 60, | |
minCutoff: 2, | |
beta: 0.015, | |
dcutoff: 1, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { PinchButton } from "SpectaclesInteractionKit/Components/UI/PinchButton/PinchButton"; | |
@component | |
export class ToggleImage extends BaseScriptComponent { | |
@input | |
image: Image; | |
onAwake() { | |
this.sceneObject | |
.getComponent(PinchButton.getTypeName()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { WebSocketConnection } from "./Scripts/WebSocketConnection"; | |
@component | |
export class SampleUsageWebSocket extends BaseScriptComponent { | |
private websocket: WebSocketConnection; | |
onAwake() { | |
this.websocket = new WebSocketConnection(); | |
this.websocket.onMessage((event) => { | |
this.receiveAudioFromServer(event); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Event from "SpectaclesInteractionKit/Utils/Event"; | |
const HOST = "wss://[APP_NAME].herokuapp.com"; | |
export class WebSocketConnection { | |
private remoteServiceModule: RemoteServiceModule = require("LensStudio:RemoteServiceModule"); | |
private webSocket: WebSocket; | |
private onMessageEvent = new Event<WebSocketMessageEvent>(); | |
public readonly onMessage = this.onMessageEvent.publicApi(); |