{-# LANGUAGE OverloadedStrings #-} module Main where import Network.Mime(defaultMimeLookup) import VoicebaseClient import Options import qualified Data.ByteString.Lazy as LBS data MainOptions = MainOptions { token :: Maybe BearerToken, targetFile :: Maybe FilePath } instance Options MainOptions where defineOptions = pure MainOptions <*> simpleOption "bearer-token" Nothing "The bearer token obtained from voicebase" <*> simpleOption "file" Nothing "The file to be posted" main :: IO () main = runCommand $ \opts args -> do case token opts of Just bearToken -> case targetFile opts of Just file -> withBearAndFile bearToken file Nothing -> putStrLn "file required" Nothing -> putStrLn "bearer token required" withBearAndFile :: BearerToken -> FilePath -> IO() withBearAndFile bearToken file = do -- result <- transcribeFile bearToken file bytes <- LBS.readFile file result <- transcribeBytes bearToken (LazyByteFile bytes (defaultMimeLookup "f.mp3")) putStrLn . show $ result