Optional calls
Split Textsegment
Split Textsegment
The splitTextsegment mutation splits one text segment into two or more, each optionally assigned to a different speaker. The original segment is deleted and positions are shifted automatically.
Use this to correct speaker attribution at the segment level — for example, when two speakers were merged into a single segment during transcription.
Input
-
textsegmentId(Int!) — The ID of the segment to split. Retrieve segment IDs fromgetTextsegmentsByProtocolAndPageorgetTranscriptByAgendaItemId. -
newSegments([NewSegmentInput!]!) — List of new segments to create in place of the original. Each segment has:speakerSlug(String!) — The speaker to assign. Use the keys fromspeakerListingetProtocolBySlug.textJson([TextJsonInput!]!) — List of word/sentence objects withtext,startTime, andendTime.
GraphQL Mutation
mutation SplitTextsegment(
$textsegmentId: Int!
$newSegments: [NewSegmentInput!]!
) {
splitTextsegment(
textsegmentId: $textsegmentId
newSegments: $newSegments
) {
success
newTextsegmentIds
}
}
Mutation Variables
{
"textsegmentId": 123,
"newSegments": [
{
"speakerSlug": "spk-abc",
"textJson": [
{ "text": "Erster Satz.", "startTime": 0.0, "endTime": 2.5 }
]
},
{
"speakerSlug": "spk-def",
"textJson": [
{ "text": "Zweiter Satz.", "startTime": 2.5, "endTime": 5.0 }
]
}
]
}
Response
success— Whether the split was successful.newTextsegmentIds— IDs of the newly created segments in order.
Example JavaScript Implementation
import axios from "axios";
async function splitTextsegment(textsegmentId, newSegments) {
try {
const response = await axios({
method: "POST",
url: "https://api-v2.speechmind.com/external/v2/graphql",
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.SPEECHMIND_API_KEY,
},
data: JSON.stringify({
query: SPLIT_TEXTSEGMENT,
variables: { textsegmentId, newSegments },
}),
});
const data = response.data.data.splitTextsegment;
if (data.success) {
console.log("Segment split successfully. New IDs:", data.newTextsegmentIds);
}
} catch (error) {
console.error("Error splitting textsegment:", error);
}
}
// Example usage
splitTextsegment(123, [
{
speakerSlug: "spk-abc",
textJson: [{ text: "Erster Satz.", startTime: 0.0, endTime: 2.5 }],
},
{
speakerSlug: "spk-def",
textJson: [{ text: "Zweiter Satz.", startTime: 2.5, endTime: 5.0 }],
},
]);
Notes
- The original segment is deleted — this action cannot be undone.
startTimeandendTimeshould match the original segment’s timing. The audio itself is not modified.speakerSlugvalues come from thespeakerListobject returned bygetProtocolBySlug.
Have questions?
Still have questions? Talk to support.