packages feed

speechmatics 0.5.0.0 → 0.6.0.0

raw patch · 3 files changed

+17/−9 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Speechmatics.Client: [model] :: ByteConfig -> ModelName
- Speechmatics.Client: type ModelName = String
+ Speechmatics.Client: [config] :: ByteConfig -> Value
- Speechmatics.Client: ByteConfig :: Location -> ModelName -> ByteConfig
+ Speechmatics.Client: ByteConfig :: Location -> Value -> ByteConfig

Files

app/Main.hs view
@@ -10,6 +10,7 @@ import Speechmatics.Client  import Network.Mime(MimeType) import Data.Text(pack, Text)+import           Data.Aeson                  (decode)  data MainOptions = MainOptions     { @@ -41,6 +42,12 @@   let mime = (defaultMimeLookup "d.mp3")   print mime   print . sha256 $ bytes-  result <- runStdoutLoggingT $ transcribeBytes (ByteConfig (Location JsonV2 "http://192.168.38.91:8082/v1/user/" userId Nothing) "en-AU") (LoadedFile bytes file mime)-  putStrLn . show $ result+  case decode "{ \"type\": \"transcription\", \"transcription_config\": { \"language\": \"en-AU\", \"diarization\": \"channel\", \"channel_diarization_labels\": [\"Agent\", \"Caller\"] } }" of+    Just json -> do+      result <- runStdoutLoggingT $ transcribeBytes (ByteConfig (Location JsonV2 "http://192.168.38.91:8082/v1/user/" userId Nothing) +          -- "{ \"type\": \"transcription\", \"transcription_config\": { \"language\": \"en-AU\", \"diarization\": \"channel\", \"channel_diarization_labels\": [\"Agent\", \"Caller\"] } }") +          json) +          (LoadedFile bytes file mime)+      putStrLn . show $ result+    Nothing -> return () 
speechmatics.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: db9c3ccd92a7f21fe5f04addcde9142dba3b2245ec662671ddb9d0acb2494fee+-- hash: cc509a2a8595bbf451ac07ba7f538d6fce13a779255b88f9e04880c1420bb01b  name:           speechmatics-version:        0.5.0.0+version:        0.6.0.0 synopsis:       Speechmatics api client description:    Upload audio files to speechmatics to get a transcription category:       API@@ -55,6 +55,7 @@   ghc-options: -threaded -rtsopts -with-rtsopts=-N   build-depends:       SHA+    , aeson     , base >=4.7 && <5     , bytestring     , mime-types
src/Speechmatics/Client.hs view
@@ -6,7 +6,6 @@   transcribe,   AuthToken,   UserID,-  ModelName,   LoadedFile(..),   Error(..),   Format(..),@@ -23,7 +22,7 @@ import           OpenSSL.Session             (context)  import           Data.Aeson                  (FromJSON (parseJSON), Value,-                                              eitherDecode)+                                              eitherDecode, encode) import           Network.HTTP.Client         (defaultManagerSettings,                                               managerResponseTimeout,                                               responseTimeoutMicro)@@ -85,7 +84,7 @@ -- | Configuration data for transcribeBytes function data ByteConfig = ByteConfig {   location :: Location,-  model    :: ModelName+  config :: Value }  makeOpts :: Options@@ -103,14 +102,15 @@ -- | Transcribe a file that is already loaded in memory --   Does not catch exeptions transcribeBytes :: ByteConfig -> LoadedFile -> LoggingT IO(Either Error Value)-transcribeBytes (ByteConfig location model) (LoadedFile content filename mimetype) =+transcribeBytes (ByteConfig location config) (LoadedFile content filename mimetype) = do+  debug $ pack $ show parts   transcribe location defaults parts   where     parts = [         partLBS inputName content           & partContentType ?~ mimetype           & partFileName ?~ filename,-        partString modelName model+        partLBS "config" $ encode config       ]  withAuthorization :: Options -> Options