我已經處理了一些音頻文件,但我只有這樣一個URL:如何在python中播放ogg stream url?
https://stream.watsonplatform.net/text-to-speech/api/v1/synthesize?voice=en-US_LisaVoice&text=How%20can%20I%20help%20you%20today.&watson-token=r4H7NZRIVbmROHTbd6Bw6NskKwtLAmowO1Roz%2F2e0HzvdkV7iFxJGKnI8Yk%2BWRL13lBppUzSyef1gRjL2gMuQeAu%2BkEgC9JX9G9hG6sedhvC6FHVIlsWsykkjcWsP%2FxBUzXujYdOJHNoTXoDK2MOZAsD%2F155m44REIZYsyWWk7Pnl9fJNjfZQlu4lIMt38VIJKNq9UXBlTB%2FibSW57H7yRGuoEw0RUrAd6oDSt0qYEewEm0Qr6azD98HeL0NjKRcgiiEpJIwJNyXr6mwYFT7bMpq2qswZD56GtgrXkDoF2NZqi2snSk4XzFubSQsO0oE95bs3jm4VPLukQKnyDD9T63P%2B3%2FVhFokRP%2BA8%2BZ%2FITQu%2FYLo3p6juVTUsXGPL5dEU7JmHpuFSqfQQ%2FHiKJTkJiVRZJ%2B0bjoj9yzy3iDQ%2BEGhKzLxng%2BxOX7qkpoo8DVRUrGrnuCoHaQ04OmS10Ic8AVMVvgYmoJOJ8gntCBDwO5ucjn9xVpkONmzHB%2FJs6NJ%2FJc%2BYkOJsKvo2SNW39U2lE8Mrj2Q%2F0XjPzVKQ%2B40oP2oRPDA0RpvXe09Ka1JHFczt5sxQ8W8YJcKUyXJkmlZ%2FGWnmSDG17Yr4LuolUjnn38lNzhn026VwrQ7LqVYVKoc8hmfwxTDr%2BAuL%2Bv4TYGYW75JJNVzdPN5mgbI32a%2F15YHSnykpCECTQ1PzOT3TaaCu41qV6wsqHCCd%2FaGF3jsvUo%2BWQWDZq%2FM0fkbnsyYaHyOO4AAkm9nADnRiD%2FLLuoHERtuay2YhsyJKagNU4YXJ0ISakxfFvs9K1OnLIRInYliWW84DVDVLLnJHhOBFMUH4vytECdAh2%2BNlwDE2GnzgHDg9QSieItFLnYC6tp2BLSL02502%2Fjv1sw4TEfWETCcTwsK8zPc8g%2F3KX7Pwf24ZgUcjzfXtZiwjVc70vPQsxjxTzLqTzP7Mo61QLmSOkFL&accept=audio%2Fogg
這似乎是一個流URL,這樣我怎麼能發揮它,而不是直接保存爲一個文件?
TKS,這是works.but我想打它,而不是直接保存爲一個文件,讓你有一些好主意嗎? – wangcs
您可以使用'StringIO(r.content)'(或Python3中的BytesIO)創建一個內存文件,但是您必須找到一個將從類文件對象而不是真實文件播放的庫。 –
upvoting,因爲這最好地回答了OP的請求。 –