開始使用免費開始

翻譯葡萄牙語

OpenAI 的語音模型不僅能將音訊轉寫為其原始語言,還支援翻譯功能,能產生英文轉寫。

在這個練習中,你會再次使用葡萄牙語的音檔,但這次要把它翻譯成英文!

本練習屬於課程

使用 OpenAI API 的多模態系統

檢視課程

練習說明

  • 開啟 audio.m4a 檔案。
  • 向 Audio 端點建立一個翻譯請求。
  • 從回應中擷取並列印翻譯後的文字。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

client = OpenAI(api_key="")

# Open the audio.m4a file
audio_file = ____(____, "rb")

# Create a translation from the audio file
response = client.audio.____.____(model="whisper-1", file=____)

# Extract and print the translated text
print(response.____)
編輯並執行程式碼