module TD.Data.SpeechRecognitionModels
(SpeechRecognitionModels(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.SpeechRecognitionModel as SpeechRecognitionModel
import qualified TD.Data.Document as Document
data SpeechRecognitionModels
= SpeechRecognitionModels
{ SpeechRecognitionModels -> Maybe [SpeechRecognitionModel]
models :: Maybe [SpeechRecognitionModel.SpeechRecognitionModel]
, SpeechRecognitionModels -> Maybe Document
language_detection_model :: Maybe Document.Document
, SpeechRecognitionModels -> Maybe Document
voice_activity_detection_model :: Maybe Document.Document
}
deriving (SpeechRecognitionModels -> SpeechRecognitionModels -> Bool
(SpeechRecognitionModels -> SpeechRecognitionModels -> Bool)
-> (SpeechRecognitionModels -> SpeechRecognitionModels -> Bool)
-> Eq SpeechRecognitionModels
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SpeechRecognitionModels -> SpeechRecognitionModels -> Bool
== :: SpeechRecognitionModels -> SpeechRecognitionModels -> Bool
$c/= :: SpeechRecognitionModels -> SpeechRecognitionModels -> Bool
/= :: SpeechRecognitionModels -> SpeechRecognitionModels -> Bool
Eq, Int -> SpeechRecognitionModels -> ShowS
[SpeechRecognitionModels] -> ShowS
SpeechRecognitionModels -> String
(Int -> SpeechRecognitionModels -> ShowS)
-> (SpeechRecognitionModels -> String)
-> ([SpeechRecognitionModels] -> ShowS)
-> Show SpeechRecognitionModels
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SpeechRecognitionModels -> ShowS
showsPrec :: Int -> SpeechRecognitionModels -> ShowS
$cshow :: SpeechRecognitionModels -> String
show :: SpeechRecognitionModels -> String
$cshowList :: [SpeechRecognitionModels] -> ShowS
showList :: [SpeechRecognitionModels] -> ShowS
Show)
instance I.ShortShow SpeechRecognitionModels where
shortShow :: SpeechRecognitionModels -> String
shortShow SpeechRecognitionModels
{ models :: SpeechRecognitionModels -> Maybe [SpeechRecognitionModel]
models = Maybe [SpeechRecognitionModel]
models_
, language_detection_model :: SpeechRecognitionModels -> Maybe Document
language_detection_model = Maybe Document
language_detection_model_
, voice_activity_detection_model :: SpeechRecognitionModels -> Maybe Document
voice_activity_detection_model = Maybe Document
voice_activity_detection_model_
}
= String
"SpeechRecognitionModels"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"models" String -> Maybe [SpeechRecognitionModel] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [SpeechRecognitionModel]
models_
, String
"language_detection_model" String -> Maybe Document -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Document
language_detection_model_
, String
"voice_activity_detection_model" String -> Maybe Document -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Document
voice_activity_detection_model_
]
instance AT.FromJSON SpeechRecognitionModels where
parseJSON :: Value -> Parser SpeechRecognitionModels
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"speechRecognitionModels" -> Value -> Parser SpeechRecognitionModels
parseSpeechRecognitionModels Value
v
String
_ -> Parser SpeechRecognitionModels
forall a. Monoid a => a
mempty
where
parseSpeechRecognitionModels :: A.Value -> AT.Parser SpeechRecognitionModels
parseSpeechRecognitionModels :: Value -> Parser SpeechRecognitionModels
parseSpeechRecognitionModels = String
-> (Object -> Parser SpeechRecognitionModels)
-> Value
-> Parser SpeechRecognitionModels
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"SpeechRecognitionModels" ((Object -> Parser SpeechRecognitionModels)
-> Value -> Parser SpeechRecognitionModels)
-> (Object -> Parser SpeechRecognitionModels)
-> Value
-> Parser SpeechRecognitionModels
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [SpeechRecognitionModel]
models_ <- Object
o Object -> Key -> Parser (Maybe [SpeechRecognitionModel])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"models"
Maybe Document
language_detection_model_ <- Object
o Object -> Key -> Parser (Maybe Document)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"language_detection_model"
Maybe Document
voice_activity_detection_model_ <- Object
o Object -> Key -> Parser (Maybe Document)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"voice_activity_detection_model"
SpeechRecognitionModels -> Parser SpeechRecognitionModels
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SpeechRecognitionModels -> Parser SpeechRecognitionModels)
-> SpeechRecognitionModels -> Parser SpeechRecognitionModels
forall a b. (a -> b) -> a -> b
$ SpeechRecognitionModels
{ models :: Maybe [SpeechRecognitionModel]
models = Maybe [SpeechRecognitionModel]
models_
, language_detection_model :: Maybe Document
language_detection_model = Maybe Document
language_detection_model_
, voice_activity_detection_model :: Maybe Document
voice_activity_detection_model = Maybe Document
voice_activity_detection_model_
}
parseJSON Value
_ = Parser SpeechRecognitionModels
forall a. Monoid a => a
mempty