概觀
VoicevoxResponse 是 talk()->generate() 或 song()->generate() 等合成執行方法所傳回的回應物件。Client 模式與 Native 模式使用相同的 VoicevoxResponse。
內部保存 WAV 格式的 binary 資料,並提供儲存、轉換、字串化的 utility。
content()
content() 回傳原始 WAV binary。可用於直接作為 HTTP response 回傳。
storeAs()
storeAs() 將 WAV 儲存至 Laravel 的 Storage。參數與 Storage::put() 的概念相同。
string)。儲存失敗時回傳 false。
toBase64()
toBase64() 將 WAV binary 轉為 Base64 字串。可用於 JSON response 或嵌入 HTML。
__toString()
將 VoicevoxResponse 轉型為字串時,會回傳與 content() 相同的 WAV binary。