diff --git a/scripts/transcribe-call.js b/scripts/transcribe-call.js new file mode 100644 index 0000000..4950b83 --- /dev/null +++ b/scripts/transcribe-call.js @@ -0,0 +1,275 @@ +import { ParameterType } from 'jspsych'; +import html from '../utils/html.js'; + + const info = { + name: "transcribe-call", + parameters: { + + }, + }; + + class jsPsychTranscribeCall { + constructor(jsPsych) { + this.jsPsych = jsPsych; + } + static { + this.info = info; + } + + + trial(display_element, trial) { + // Get the original recording data from the record-call trial + // Look through recent trials to find one with recording response + const allData = this.jsPsych.data.get(); + const recentTrials = allData.trials.slice(-10); // Look at last 10 trials + + let recordingData = null; + for (let i = recentTrials.length - 1; i >= 0; i--) { + const trial = recentTrials[i]; + if (trial.response && typeof trial.response === 'string' && trial.response.length > 100) { + // Found a trial with audio recording data + recordingData = trial; + break; + } + } + + if (!recordingData || !recordingData.response) { + display_element.innerHTML = ` +
No recording found from the previous trial.
+ +Error loading audio data.
+ +