Commit
·
691565a
1
Parent(s):
e06292f
Added validator for timestamps parameter
Browse files- handler.py +8 -0
handler.py
CHANGED
@@ -3,6 +3,7 @@ from typing import Dict, List, Any, Literal, Optional, Tuple
|
|
3 |
import torch
|
4 |
import logging
|
5 |
from pydantic_settings import BaseSettings
|
|
|
6 |
|
7 |
class EndpointHandler():
|
8 |
def __init__(self, path=""):
|
@@ -63,6 +64,13 @@ class WhisperParameterHandler(BaseSettings):
|
|
63 |
no_speech_threshold: Optional[float] = None
|
64 |
return_timestamps: Optional[Literal["word", True]] = None
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
model_config = {
|
67 |
"env_prefix": "WHISPER_KWARGS_",
|
68 |
"case_sensitive": False,
|
|
|
3 |
import torch
|
4 |
import logging
|
5 |
from pydantic_settings import BaseSettings
|
6 |
+
from pydantic import field_validator
|
7 |
|
8 |
class EndpointHandler():
|
9 |
def __init__(self, path=""):
|
|
|
64 |
no_speech_threshold: Optional[float] = None
|
65 |
return_timestamps: Optional[Literal["word", True]] = None
|
66 |
|
67 |
+
@field_validator("return_timestamps", mode="before")
|
68 |
+
def cannonize_timestamps(cls, value: Any):
|
69 |
+
if value == "True":
|
70 |
+
return True
|
71 |
+
|
72 |
+
return value
|
73 |
+
|
74 |
model_config = {
|
75 |
"env_prefix": "WHISPER_KWARGS_",
|
76 |
"case_sensitive": False,
|