|
import os |
|
import pandas as pd |
|
import requests |
|
df=pd.read_csv("MR_Words.csv") |
|
|
|
def download_audio_from_dataframe(df, url_column, folder_path): |
|
for index, row in df.iterrows(): |
|
audio_url = row[url_column] |
|
if pd.notna(audio_url) and isinstance(audio_url, str): |
|
file_name = os.path.basename(audio_url) |
|
|
|
try: |
|
|
|
os.makedirs(folder_path, exist_ok=True) |
|
|
|
|
|
full_path = os.path.join(folder_path, file_name) |
|
|
|
|
|
response = requests.get(audio_url) |
|
|
|
|
|
if response.status_code == 200: |
|
|
|
with open(full_path, 'wb') as audio_file: |
|
audio_file.write(response.content) |
|
print(f"Audio file downloaded successfully to {full_path}") |
|
else: |
|
print(f"Failed to download audio file. Status code: {response.status_code}") |
|
|
|
except Exception as e: |
|
print(f"Error: {e}") |
|
print(file_name) |
|
continue |
|
|
|
|
|
|
|
|
|
|
|
|
|
url_column_name = 'recordingserverurl' |
|
|
|
|
|
download_folder = 'path_to/Marathi/words' |
|
|
|
|
|
download_audio_from_dataframe(df, url_column_name, download_folder) |
|
|
|
|