clocks: added new BaseClock and SystemClock
This commit is contained in:
0
src/pipecat/clocks/__init__.py
Normal file
0
src/pipecat/clocks/__init__.py
Normal file
18
src/pipecat/clocks/base_clock.py
Normal file
18
src/pipecat/clocks/base_clock.py
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# Copyright (c) 2024, Daily
|
||||
#
|
||||
# SPDX-License-Identifier: BSD 2-Clause License
|
||||
#
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class BaseClock(ABC):
|
||||
|
||||
@abstractmethod
|
||||
def get_time(self) -> int:
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def start(self):
|
||||
pass
|
||||
21
src/pipecat/clocks/system_clock.py
Normal file
21
src/pipecat/clocks/system_clock.py
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# Copyright (c) 2024, Daily
|
||||
#
|
||||
# SPDX-License-Identifier: BSD 2-Clause License
|
||||
#
|
||||
|
||||
import time
|
||||
|
||||
from pipecat.clocks.base_clock import BaseClock
|
||||
|
||||
|
||||
class SystemClock(BaseClock):
|
||||
|
||||
def __init__(self):
|
||||
self._time = 0
|
||||
|
||||
def get_time(self) -> int:
|
||||
return time.monotonic_ns() - self._time if self._time > 0 else 0
|
||||
|
||||
def start(self):
|
||||
self._time = time.monotonic_ns()
|
||||
0
src/pipecat/transcriptions/__init__.py
Normal file
0
src/pipecat/transcriptions/__init__.py
Normal file
Reference in New Issue
Block a user