Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@
"outputs": [],
"source": [
"import requests\n",
"import urllib.request\n",
"import torch\n",
"from pathlib import Path\n",
"from PIL import Image\n",
"import soundfile\n",
"from transformers import AutoModelForCausalLM, AutoProcessor, GenerationConfig,pipeline,AutoTokenizer"
Expand Down Expand Up @@ -360,6 +362,34 @@
"prompt = f'{system_prompt}You are a technology journalist who writes professional content based on audio and picture content{prompt_suffix}{user_prompt}Reorganize the content provided by audio <|audio_1|> and image <|image_1|> from a professional perspective and write a press release based on the current development of AI ,output is markdown format and including title and content {prompt_suffix}{assistant_prompt}'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"media_dir = Path(\"media\")\n",
"media_dir.mkdir(exist_ok=True)\n",
"\n",
"image_path = media_dir / \"copilot.png\"\n",
"audio_path = media_dir / \"sample_audio.mp3\"\n",
"\n",
"sample_media = {\n",
" image_path: \"https://raw.githubusercontent.com/microsoft/PhiCookBook/main/imgs/02/pfonnx/pfv.png\",\n",
" audio_path: \"https://raw.githubusercontent.com/Azure-Samples/cognitive-services-speech-sdk/master/samples/csharp/sharedcontent/console/whatstheweatherlike.mp3\",\n",
"}\n",
"\n",
"for path, url in sample_media.items():\n",
" if not path.exists():\n",
" try:\n",
" with urllib.request.urlopen(url, timeout=30) as response, open(path, \"wb\") as out_file:\n",
" out_file.write(response.read())\n",
" except Exception as exc:\n",
" raise RuntimeError(\n",
" f\"Failed to download {path.name} from {url}. Download it manually and place it under {media_dir}/\"\n",
" ) from exc"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -368,7 +398,8 @@
},
"outputs": [],
"source": [
"image = Image.open(\"./copilot.png\")"
"with Image.open(image_path) as img:\n",
" image = img.copy()"
]
},
{
Expand All @@ -379,7 +410,7 @@
},
"outputs": [],
"source": [
"audio = soundfile.read('./satya1.mp3')"
"audio = soundfile.read(audio_path)"
]
},
{
Expand Down