-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transcription events CLT-343 #406
Changes from all commits
7e29401
4f27757
4504abc
2923b65
27c9deb
9dacd3c
6d4f49c
7d5447b
a65912c
b13767a
dd947e8
557c84e
1ddd2d8
f98bf8e
6a5be85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright 2024 LiveKit | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import Foundation | ||
|
||
@objc | ||
public class TranscriptionSegment: NSObject { | ||
public let id: String | ||
public let text: String | ||
public let language: String | ||
public let startTime: UInt64 | ||
public let endTime: UInt64 | ||
public let isFinal: Bool | ||
|
||
init(id: String, | ||
text: String, | ||
language: String, | ||
startTime: UInt64, | ||
endTime: UInt64, | ||
isFinal: Bool) | ||
{ | ||
self.id = id | ||
self.text = text | ||
self.language = language | ||
self.startTime = startTime | ||
self.endTime = endTime | ||
self.isFinal = isFinal | ||
} | ||
|
||
// MARK: - Equal | ||
|
||
override public func isEqual(_ object: Any?) -> Bool { | ||
guard let other = object as? Self else { return false } | ||
return id == other.id | ||
} | ||
|
||
override public var hash: Int { | ||
var hasher = Hasher() | ||
hasher.combine(id) | ||
return hasher.finalize() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hiroshihorie @lukasIO do you two think it's right to identify and hash these based on ID alone? It doesn't guarantee true equality, because a newer version could be received later that should be used instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the intended purpose of the hash? |
||
} | ||
} | ||
|
||
// MARK: - Internal | ||
|
||
extension Livekit_TranscriptionSegment { | ||
func toLKType() -> TranscriptionSegment { | ||
TranscriptionSegment(id: id, | ||
text: text, | ||
language: language, | ||
startTime: startTime, | ||
endTime: endTime, | ||
isFinal: final) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hiroshihorie you'll need to include support for transcription events coming down on the LocalParticipant as well, to record the results of STT in the agent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick spike and it works to just change the delegate methods to receive generic Participant and TrackPublication instead of the Remote variants, change these lines up here to the following
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you ! will update.