From 6a1c6790b623ff1f8ec82f08e091b83d8877b7f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dcaro?= Date: Mon, 25 Sep 2023 21:28:23 -0300 Subject: [PATCH 1/2] Updating BasedSettings --- howl/model/cnn.py | 2 +- howl/model/rnn.py | 2 +- howl/settings.py | 2 +- howl/utils/dataclass.py | 2 +- requirements.txt | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/howl/model/cnn.py b/howl/model/cnn.py index 72c224cf..b4d927d4 100644 --- a/howl/model/cnn.py +++ b/howl/model/cnn.py @@ -1,6 +1,6 @@ from typing import Tuple -from pydantic import BaseSettings +from pydantic_settings import BaseSettings from torchvision.models import MobileNetV2, mobilenet_v2 import torch import torch.nn as nn diff --git a/howl/model/rnn.py b/howl/model/rnn.py index 48ea44e6..d9d9803f 100644 --- a/howl/model/rnn.py +++ b/howl/model/rnn.py @@ -3,7 +3,7 @@ import torch import torch.nn as nn import torch.nn.functional as F -from pydantic import BaseSettings +from pydantic_settings import BaseSettings from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence from .base import RegisteredModel diff --git a/howl/settings.py b/howl/settings.py index e1c54b08..cd791a26 100644 --- a/howl/settings.py +++ b/howl/settings.py @@ -1,7 +1,7 @@ import multiprocessing from typing import List -from pydantic import BaseSettings +from pydantic_settings import BaseSettings __all__ = ["AudioSettings", "DatasetSettings", "SETTINGS"] diff --git a/howl/utils/dataclass.py b/howl/utils/dataclass.py index bcca72ba..038c4090 100644 --- a/howl/utils/dataclass.py +++ b/howl/utils/dataclass.py @@ -1,6 +1,6 @@ import json -from pydantic import BaseSettings +from pydantic_settings import BaseSettings from pathlib import PosixPath diff --git a/requirements.txt b/requirements.txt index 6cb7d1a8..28f1e89e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ praat-textgrids==1.3.1 protobuf==3.19.4 # Protobuf 4.21.0 contains a breaking change for Python, as explained here: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates pyaudio pydantic>=1.7.3 +pydantic_settings pytest==6.2.3 pytest-timeout==2.1.0 soundfile==0.10.3.post1 From 01ea4399973d5610004ca8dcaa014ba0eabb569c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8Dcaro?= Date: Mon, 25 Sep 2023 21:45:28 -0300 Subject: [PATCH 2/2] Fixed various compatibility issues --- howl/client/howl_client.py | 2 +- howl/settings.py | 8 ++++---- requirements.txt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/howl/client/howl_client.py b/howl/client/howl_client.py index 711e72da..17bd4ab8 100644 --- a/howl/client/howl_client.py +++ b/howl/client/howl_client.py @@ -109,7 +109,7 @@ def _on_audio(self, in_data, frame_count, time_info, status_flags): return data_ok def _normalize_audio(self, audio_data): - return np.frombuffer(audio_data, dtype=np.int16).astype(np.float) / self._audio_float_size + return np.frombuffer(audio_data, dtype=np.int16).astype(float) / self._audio_float_size def start(self): """Start the audio stream for inference""" diff --git a/howl/settings.py b/howl/settings.py index cd791a26..e9e8b313 100644 --- a/howl/settings.py +++ b/howl/settings.py @@ -1,5 +1,5 @@ import multiprocessing -from typing import List +from typing import List, Optional from pydantic_settings import BaseSettings @@ -38,7 +38,7 @@ class AudioTransformSettings(BaseSettings): class InferenceEngineSettings(BaseSettings): """Base settings for inference engine""" - inference_weights: List[float] = None + inference_weights: Optional[List[float]] = None inference_sequence: List[int] = [0] inference_window_ms: float = 2000 # look at last of these seconds smoothing_window_ms: float = 50 # prediction smoothed @@ -66,9 +66,9 @@ class TrainingSettings(BaseSettings): objective: str = "frame" # frame or ctc # TODO: support phone token_type token_type: str = "word" - phone_dictionary: str = None + phone_dictionary: Optional[str] = None use_noise_dataset: bool = False - noise_dataset_path: str = None + noise_dataset_path: Optional[str] = None class DatasetSettings(BaseSettings): diff --git a/requirements.txt b/requirements.txt index 28f1e89e..3ea4a074 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ pytest==6.2.3 pytest-timeout==2.1.0 soundfile==0.10.3.post1 tensorboard==2.8.0 -torch==1.10.1 +torch>=1.10.1 torchaudio>=0.5.0 torchvision>=0.6.0 tqdm