title: Covert curl request to http post request in swift and then download audio file
body: <p>How can I convert this curl request to a proper HTTP request in swift:</p>
  <pre><code>curl --location --request POST https://$region.tts.speech.microsoft.com/cognitiveservices/v1' \
  --header 'Ocp-Apim-Subscription-Key: $key' \
  --header 'Content-Type: application/ssml+xml' \
  --header 'X-Microsoft-OutputFormat: audio-16khz-128kbitrate-mono-mp3' \
  --header 'User-Agent: curl' \
  --data-raw '&lt;speak version='\''1.0'\'' xml:lang='\''en-US'\''&gt;
                      &lt;voice xml:lang='\''en-US'\'' xml:gender='\''Female'\'' name='\''en-US-JennyNeural'\''&gt;
                          my voice is my passport verify me
                      &lt;/voice&gt;
                  &lt;/speak&gt;' &gt; output.mp3
  </code></pre>
  <p>The <code>--data-raw</code> part is quite confusing.</p>
  <p>This is what I have so far:</p>
  <pre><code>   func textToSpeech(transcript: String) async throws {
          
          let key = MICROSOFT_SUB_KEY
          let region = &quot;eastus&quot;
       
          
          
          guard let url = URL(string: &quot;https://\(region).tts.speech.microsoft.com/cognitiveservices/v1&quot;) else { fatalError(&quot;Missing URL&quot;) }
          var request = URLRequest(url: url)
          request.setValue((key as! String), forHTTPHeaderField: &quot;Ocp-Apim-Subscription-Key&quot;)
          request.setValue(&quot;application/ssml+xml&quot;, forHTTPHeaderField: &quot;Content-Type&quot;)
          request.setValue(&quot;audio-16khz-128kbitrate-mono-mp3&quot;, forHTTPHeaderField: &quot;X-Microsoft-OutputFormat&quot;)
          request.setValue(&quot;curl&quot;, forHTTPHeaderField: &quot;User-Agent&quot;)
          
          request.httpBody = &quot;&lt;speak version='\''1.0'\'' xml:lang='\''en-US'\''&gt;&lt;voice xml:lang='\''en-US'\'' xml:gender='\''Female'\'' name='\''en-US-JennyNeural'\''&gt;my voice is my passport verify me&lt;/voice&gt;&lt;/speak&gt;&quot;
          
          request.httpMethod = &quot;POST&quot;
         
          let (_, response) = try await URLSession.shared.data(for: request)
          guard (response as? HTTPURLResponse)?.statusCode == 200 else { fatalError(&quot;Error while fetching data&quot;) }
      }
  </code></pre>
  <p>And then finally, how can I download the audio file locally?</p>