Spaces:
Runtime error
Runtime error
Update AzureBlobStorageAudio.py
#24
by Shashika-HF - opened
- AzureBlobStorageAudio.py +17 -1
AzureBlobStorageAudio.py
CHANGED
|
@@ -9,6 +9,17 @@ container_name = "useruploadhuggingfaceaudio" # Update container name for audio
|
|
| 9 |
file_path = r"C:\Users\ASUS\Desktop\UoW\2ND YEAR\SDGP\AUDIO\edit\3_second_audio.flac" # Update path to your MP3 file
|
| 10 |
file_name = "uploaded_audio.mp3"
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
def uploadUserAudioToBlobStorage(file_path, file_name):
|
| 14 |
"""Uploads an MP3 audio file to the specified Azure Blob Storage container and returns the URL.
|
|
@@ -39,6 +50,9 @@ def uploadUserAudioToBlobStorage(file_path, file_name):
|
|
| 39 |
# Upload the audio data to the blob
|
| 40 |
upload_blob_result = blob_client.upload_blob(data)
|
| 41 |
|
|
|
|
|
|
|
|
|
|
| 42 |
# Get the URL for the uploaded blob
|
| 43 |
blob_url = blob_client.url
|
| 44 |
|
|
@@ -53,4 +67,6 @@ def uploadUserAudioToBlobStorage(file_path, file_name):
|
|
| 53 |
if __name__ == "__main__":
|
| 54 |
# Example usage
|
| 55 |
uploaded_audio_url = uploadUserAudioToBlobStorage(file_path, file_name)
|
| 56 |
-
#
|
|
|
|
|
|
|
|
|
| 9 |
file_path = r"C:\Users\ASUS\Desktop\UoW\2ND YEAR\SDGP\AUDIO\edit\3_second_audio.flac" # Update path to your MP3 file
|
| 10 |
file_name = "uploaded_audio.mp3"
|
| 11 |
|
| 12 |
+
def deleteUserAudioFromBlobStorage(blob_client):
|
| 13 |
+
"""Deletes the specified blob from Azure Blob Storage.
|
| 14 |
+
|
| 15 |
+
Args:
|
| 16 |
+
blob_client (BlobClient): The BlobClient object for the blob to delete.
|
| 17 |
+
"""
|
| 18 |
+
try:
|
| 19 |
+
blob_client.delete_blob()
|
| 20 |
+
print(f"Audio deleted successfully from Azure Blob Storage.")
|
| 21 |
+
except Exception as e:
|
| 22 |
+
print(f"Error deleting audio: {e}")
|
| 23 |
|
| 24 |
def uploadUserAudioToBlobStorage(file_path, file_name):
|
| 25 |
"""Uploads an MP3 audio file to the specified Azure Blob Storage container and returns the URL.
|
|
|
|
| 50 |
# Upload the audio data to the blob
|
| 51 |
upload_blob_result = blob_client.upload_blob(data)
|
| 52 |
|
| 53 |
+
# Get the BlobClient object for deleting process
|
| 54 |
+
blob_client = container_client.get_blob_client(file_name)
|
| 55 |
+
|
| 56 |
# Get the URL for the uploaded blob
|
| 57 |
blob_url = blob_client.url
|
| 58 |
|
|
|
|
| 67 |
if __name__ == "__main__":
|
| 68 |
# Example usage
|
| 69 |
uploaded_audio_url = uploadUserAudioToBlobStorage(file_path, file_name)
|
| 70 |
+
# use the uploaded_audio_url for further processing or sharing
|
| 71 |
+
# receive the enhanced video:
|
| 72 |
+
deleteUserAudioFromBlobStorage(blob_client)
|