Skip to content

Commit 179ce55

Browse files
committed
Simplify, simplify...
1 parent 9575996 commit 179ce55

File tree

1 file changed

+6
-11
lines changed
  • swift/example_code/transcribe/transcribe-events/Sources

1 file changed

+6
-11
lines changed

swift/example_code/transcribe/transcribe-events/Sources/entry.swift

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ struct ExampleCommand: ParsableCommand {
9999
}
100100
}
101101

102-
// Start the transcription running.
102+
// Start the transcription running on the audio stream.
103103

104104
let output = try await client.startStreamTranscription(
105105
input: StartStreamTranscriptionInput(
@@ -110,10 +110,6 @@ struct ExampleCommand: ParsableCommand {
110110
)
111111
)
112112

113-
// A variable to receive the complete text.
114-
115-
var text = ""
116-
117113
// Iterate over the events in the transcript result stream. Each
118114
// `transcriptevent` contains a list of result fragments which need
119115
// to be concatenated together to build the final transcript.
@@ -125,20 +121,19 @@ struct ExampleCommand: ParsableCommand {
125121
continue
126122
}
127123

124+
// When the complete fragment of transcribed text is ready,
125+
// print it. This could just as easily be used to draw the
126+
// text as a subtitle over a playing video, though timing
127+
// would need to be managed.
128+
128129
if !result.isPartial {
129130
print(transcript)
130-
text.append(transcript + "\n")
131131
}
132132
}
133133
default:
134134
print("Error: Unexpected message from Amazon Transcribe:")
135135
}
136136
}
137-
138-
print("Transcription complete.")
139-
print("-----------------------")
140-
print(text)
141-
print("-----------------------")
142137
}
143138
}
144139

0 commit comments

Comments
 (0)