Fix/tts region use tts_time_to_first_byte streaming api (#391)

* tts region tts_time_to_first_byte_ms

* wip
This commit is contained in:
Hoan Luu Huu
2024-01-24 22:19:46 +07:00
committed by GitHub
parent c804d60664
commit 7f72d739cd
@@ -259,11 +259,18 @@ export const Player = ({ call }: PlayerProps) => {
if (!r) {
const start =
(s.startTimeUnixNano - startPoint.startTimeUnixNano) / 1_000_000_000;
const end =
let end =
(s.endTimeUnixNano - startPoint.startTimeUnixNano) / 1_000_000_000;
const [ttsVendor] = getSpanAttributeByName(s.attributes, "tts.vendor");
const [ttsCache] = getSpanAttributeByName(s.attributes, "tts.cached");
const [streamLatency] = getSpanAttributeByName(
s.attributes,
"tts_time_to_first_byte_ms"
);
if (streamLatency && streamLatency.value.stringValue) {
end = start + Number(streamLatency.value.stringValue) / 1_000;
}
if (ttsVendor && ttsCache && !Boolean(ttsCache.value.boolValue)) {
const latencyRegion = waveSurferRegionsPluginRef.current.addRegion({
id: s.spanId,