Add csv export (#368)

This commit is contained in:
Chidi Williams 2023-03-05 10:38:15 +00:00 committed by GitHub
commit c9045dc376
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 13 deletions

View file

@ -860,8 +860,8 @@
filePath = "Buzz/TranscriptionExporter.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "70"
endingLineNumber = "70"
startingLineNumber = "75"
endingLineNumber = "75"
landmarkName = "export(transcription:format:)"
landmarkType = "7">
</BreakpointContent>
@ -870,14 +870,14 @@
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "1140C7DF-92BB-4FE0-B2D7-85617DBA41DC"
shouldBeEnabled = "Yes"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Buzz/TranscriptionExporter.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "71"
endingLineNumber = "71"
startingLineNumber = "76"
endingLineNumber = "76"
landmarkName = "export(transcription:format:)"
landmarkType = "7">
</BreakpointContent>

View file

@ -76,7 +76,7 @@ struct ContentView: View {
transcriber.start() { segment in
DispatchQueue.main.async {
line = segment.text
currentRecordingTranscription?.segments.insert(segment, at: 0)
currentRecordingTranscription?.segments.append(segment)
}
}
self.transcriber = transcriber

View file

@ -8,5 +8,5 @@
import Foundation
enum ExportFormat: String, CaseIterable {
case TXT, SRT, VTT
case CSV, SRT, TXT, VTT
}

View file

@ -64,6 +64,11 @@ class TranscriptionExporter {
.appending("\(toTimestamp(ms: startMS)) --> \(toTimestamp(ms: endMS))\n")
.appending("\(segment.text)\n\n")
}
case .CSV:
output = output.appending("Start time (ms), End time (ms),Text\n")
transcription.segments.forEach { segment in
output = output.appending("\(segment.startMS ?? 0),\(segment.endMS ?? 0),\"\(segment.text)\"\n")
}
}
do {

View file

@ -1,6 +0,0 @@
# Buzz.swift
## TODO
- Save transcriptions to disk
- Export transcription to TXT, SRT, VTT