{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.AlexaBusiness.Types.Audio
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AlexaBusiness.Types.Audio where

import Amazonka.AlexaBusiness.Types.Locale
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The audio message. There is a 1 MB limit on the audio file input and the
-- only supported format is MP3. To convert your MP3 audio files to an
-- Alexa-friendly,
--
-- required codec version (MPEG version 2) and bit rate (48 kbps), you
-- might use converter software. One option for this is a command-line
-- tool, FFmpeg. For more information, see
-- <https://www.ffmpeg.org/ FFmpeg>. The following command converts the
-- provided \<input-file> to an MP3 file that is played in the
-- announcement:
--
-- @ffmpeg -i \<input-file> -ac 2 -codec:a libmp3lame -b:a 48k -ar 16000 \<output-file.mp3>@
--
-- /See:/ 'newAudio' smart constructor.
data Audio = Audio'
  { -- | The locale of the audio message. Currently, en-US is supported.
    Audio -> Locale
locale :: Locale,
    -- | The location of the audio file. Currently, S3 URLs are supported. Only
    -- S3 locations comprised of safe characters are valid. For more
    -- information, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#Safe%20Characters Safe Characters>.
    Audio -> Text
location :: Prelude.Text
  }
  deriving (Audio -> Audio -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Audio -> Audio -> Bool
$c/= :: Audio -> Audio -> Bool
== :: Audio -> Audio -> Bool
$c== :: Audio -> Audio -> Bool
Prelude.Eq, ReadPrec [Audio]
ReadPrec Audio
Int -> ReadS Audio
ReadS [Audio]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Audio]
$creadListPrec :: ReadPrec [Audio]
readPrec :: ReadPrec Audio
$creadPrec :: ReadPrec Audio
readList :: ReadS [Audio]
$creadList :: ReadS [Audio]
readsPrec :: Int -> ReadS Audio
$creadsPrec :: Int -> ReadS Audio
Prelude.Read, Int -> Audio -> ShowS
[Audio] -> ShowS
Audio -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Audio] -> ShowS
$cshowList :: [Audio] -> ShowS
show :: Audio -> String
$cshow :: Audio -> String
showsPrec :: Int -> Audio -> ShowS
$cshowsPrec :: Int -> Audio -> ShowS
Prelude.Show, forall x. Rep Audio x -> Audio
forall x. Audio -> Rep Audio x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Audio x -> Audio
$cfrom :: forall x. Audio -> Rep Audio x
Prelude.Generic)

-- |
-- Create a value of 'Audio' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'locale', 'audio_locale' - The locale of the audio message. Currently, en-US is supported.
--
-- 'location', 'audio_location' - The location of the audio file. Currently, S3 URLs are supported. Only
-- S3 locations comprised of safe characters are valid. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#Safe%20Characters Safe Characters>.
newAudio ::
  -- | 'locale'
  Locale ->
  -- | 'location'
  Prelude.Text ->
  Audio
newAudio :: Locale -> Text -> Audio
newAudio Locale
pLocale_ Text
pLocation_ =
  Audio' {$sel:locale:Audio' :: Locale
locale = Locale
pLocale_, $sel:location:Audio' :: Text
location = Text
pLocation_}

-- | The locale of the audio message. Currently, en-US is supported.
audio_locale :: Lens.Lens' Audio Locale
audio_locale :: Lens' Audio Locale
audio_locale = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Audio' {Locale
locale :: Locale
$sel:locale:Audio' :: Audio -> Locale
locale} -> Locale
locale) (\s :: Audio
s@Audio' {} Locale
a -> Audio
s {$sel:locale:Audio' :: Locale
locale = Locale
a} :: Audio)

-- | The location of the audio file. Currently, S3 URLs are supported. Only
-- S3 locations comprised of safe characters are valid. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#Safe%20Characters Safe Characters>.
audio_location :: Lens.Lens' Audio Prelude.Text
audio_location :: Lens' Audio Text
audio_location = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Audio' {Text
location :: Text
$sel:location:Audio' :: Audio -> Text
location} -> Text
location) (\s :: Audio
s@Audio' {} Text
a -> Audio
s {$sel:location:Audio' :: Text
location = Text
a} :: Audio)

instance Prelude.Hashable Audio where
  hashWithSalt :: Int -> Audio -> Int
hashWithSalt Int
_salt Audio' {Text
Locale
location :: Text
locale :: Locale
$sel:location:Audio' :: Audio -> Text
$sel:locale:Audio' :: Audio -> Locale
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Locale
locale
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
location

instance Prelude.NFData Audio where
  rnf :: Audio -> ()
rnf Audio' {Text
Locale
location :: Text
locale :: Locale
$sel:location:Audio' :: Audio -> Text
$sel:locale:Audio' :: Audio -> Locale
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Locale
locale
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
location

instance Data.ToJSON Audio where
  toJSON :: Audio -> Value
toJSON Audio' {Text
Locale
location :: Text
locale :: Locale
$sel:location:Audio' :: Audio -> Text
$sel:locale:Audio' :: Audio -> Locale
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Locale" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Locale
locale),
            forall a. a -> Maybe a
Prelude.Just (Key
"Location" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
location)
          ]
      )