['text' => $text], 'voice' => ['languageCode' => 'fr-FR', 'name' => 'fr-FR-Wavenet-A'], // Female French voice 'audioConfig' => ['audioEncoding' => 'MP3'], ]; */ // Portuguese voice $request = [ 'input' => ['text' => $text], 'voice' => ['languageCode' => 'pt-PT', 'name' => 'pt-PT-Wavenet-A'], 'audioConfig' => ['audioEncoding' => 'MP3'], ]; $options = [ 'http' => [ 'header' => "Content-type: application/json\r\n", 'method' => 'POST', 'content' => json_encode($request), ], ]; $context = stream_context_create($options); $result = file_get_contents($url, false, $context); if ($result === FALSE) { return ['success' => false, 'error' => 'API call failed']; } else { $response = json_decode($result, true); if (isset($response['audioContent'])) { $audioContent = base64_decode($response['audioContent']); file_put_contents($filename, $audioContent); return ['success' => true, 'filename' => $filename]; } else { return ['success' => false, 'error' => $response]; } } } ?>