【发布时间】:2021-12-18 21:00:09
【问题描述】:
我是 Azure 云的新手。现在我希望创建一个工作流程:将音频文件上传到 blob --> 调用 Blob 触发器 --> 部署的 python 函数读取上传的音频文件并提取谐波 --> 谐波输出为 json 文件并保存在另一个容器中. Blow 是我的代码,但它不起作用:
import logging
import azure.function as func
import audio_read
def main(myblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {myblob.name}\n"
f"Blob Size: {myblob.length} bytes")
audio_info = audioread.audio_open(myblob.read())
logging.info(f"{audio_info}")
它返回一个错误:
异常:UnicodeDecodeError:“utf-8”编解码器无法解码位置 40 中的字节 0x80:无效起始字节。
我的 function.json 是:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "examplecontainer/{name}",
"connection": "AzureWebJobsStorage"
}
]
}
【问题讨论】:
-
为什么本地运行代码(audioread.audio_open("File saved path"))没有报错?但是,一旦我在 Azure Function (audioread.audio_open("inputblob") 上运行,它就不起作用了。是我喂 blob 的方式错误吗?
-
确保将您的音频文件上传为 Blob,其中包含具有正确
content type和content encoding的二进制数据,请参阅 documentation
标签: python audio azure-functions azure-blob-storage