akshayballal commited on
Commit
95a35fc
1 Parent(s): bc626bd

chore: Add audio search functionality with Pinecone embeddings

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.wav filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import embed_anything
2
+ from embed_anything import EmbedData
3
+ from tqdm.autonotebook import tqdm
4
+ from pinecone import Pinecone, ServerlessSpec
5
+ import numpy as np
6
+ import os
7
+ from pinecone import PineconeApiException
8
+ import uuid
9
+ import re
10
+ import gradio as gr
11
+
12
+
13
+ audio_files = ["examples/samples_hp0.wav", "examples/samples_gb0.wav"]
14
+
15
+ embeddings: list[list[EmbedData]] = []
16
+
17
+ for file in audio_files:
18
+ embedding = embed_anything.embed_file(file, "Whisper-Jina")
19
+ embeddings.append(embedding)
20
+
21
+ pc = Pinecone(api_key=os.environ.get("PINECONE_API_KEY"))
22
+ pc.delete_index("search-in-audio")
23
+ try:
24
+ index = pc.create_index(
25
+ name="search-in-audio",
26
+ dimension=768, # Replace with your model dimensions
27
+ metric="cosine", # Replace with your model metric
28
+ spec=ServerlessSpec(cloud="aws", region="us-east-1"),
29
+ )
30
+ index = pc.Index("search-in-audio")
31
+ except PineconeApiException as e:
32
+ index = pc.Index("search-in-audio")
33
+ if e.status == 409:
34
+ print("Index already exists")
35
+
36
+ else:
37
+ print(e)
38
+
39
+
40
+ ## convert embeddings which is of the form EmbedData : text, embedding, metadata to the form required by pinecone which is id, values, metadata
41
+ def convert_to_pinecone_format(embeddings: list[list[EmbedData]]):
42
+ data = []
43
+ for i, embedding in enumerate(embeddings):
44
+ for j, emb in enumerate(embedding):
45
+ data.append(
46
+ {
47
+ "id": str(uuid.uuid4()),
48
+ "values": emb.embedding,
49
+ "metadata": {
50
+ "text": emb.text,
51
+ "start": emb.metadata["start"],
52
+ "end": emb.metadata["end"],
53
+ "file": re.split(r"/|\\", emb.metadata["file_name"])[-1],
54
+ },
55
+ }
56
+ )
57
+ return data
58
+
59
+
60
+ data = convert_to_pinecone_format(embeddings)
61
+ index.upsert(data)
62
+
63
+
64
+ files = ["samples_hp0.wav", "samples_gb0.wav"]
65
+
66
+
67
+ def search(query, audio):
68
+
69
+ results = []
70
+ query = embed_anything.embed_query([query], "Jina")[0]
71
+
72
+ if re.split(r"/|\\", audio)[-1] not in files:
73
+ print(file, re.split(r"/|\\", audio)[-1])
74
+ embeddings = embed_anything.embed_file(audio, "Whisper-Jina")
75
+ embeddings = convert_to_pinecone_format([embeddings])
76
+ index.upsert(embeddings)
77
+
78
+ files.append(re.split(r"/|\\", audio)[-1])
79
+
80
+ result = index.query(
81
+ vector=query.embedding,
82
+ top_k=5,
83
+ include_metadata=True,
84
+ )
85
+ for res in result.matches:
86
+ results.append(res.metadata)
87
+
88
+ formatted_results = []
89
+ for result in results:
90
+ display_text = f"""
91
+
92
+ `File: {result['file']}`
93
+
94
+ `Start: {result['start']}`
95
+
96
+ `End: {result['end']}`
97
+
98
+ Text: {result['text']}"""
99
+ formatted_results.append(display_text)
100
+
101
+ return (
102
+ formatted_results[0],
103
+ results[0]["file"],
104
+ formatted_results[1],
105
+ results[1]["file"],
106
+ formatted_results[2],
107
+ results[2]["file"],
108
+ )
109
+
110
+
111
+ demo = gr.Interface(
112
+ fn=search,
113
+ inputs=["text", gr.Audio(label="Audio", type="filepath")],
114
+ outputs=[
115
+ gr.Markdown(label="Text"),
116
+ gr.Audio(label="Audio", type="filepath"),
117
+ gr.Markdown(label="Text"),
118
+ gr.Audio(label="Audio", type="filepath"),
119
+ gr.Markdown(label="Text"),
120
+ gr.Audio(label="Audio", type="filepath"),
121
+ ],
122
+ examples=[
123
+ ["screwdriver", "examples/samples_hp0.wav"],
124
+ ["united states", "examples/samples_gb0.wav"],
125
+ ["united states", "examples/samples_hp0.wav"],
126
+ ],
127
+ )
128
+ demo.launch()
examples/samples_gb0.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:33e02d2a4eacf9e5c90053ffffd95a5fac40ff1009dd443f2a053287ed0874f7
3
+ size 4075598
examples/samples_hp0.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:12d6f3a901baf48c878bbe2a8ba7148ef8592ab5569df9fb7b0a3cd0d82b8140
3
+ size 8745688
examples/samples_jfk.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:59dfb9a4acb36fe2a2affc14bacbee2920ff435cb13cc314a08c13f66ba7860e
3
+ size 352078
requirements.txt ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiofiles==23.2.1
2
+ altair==5.3.0
3
+ annotated-types==0.7.0
4
+ anyio==4.4.0
5
+ asttokens==2.4.1
6
+ attrs==23.2.0
7
+ certifi==2024.7.4
8
+ charset-normalizer==3.3.2
9
+ click==8.1.7
10
+ colorama==0.4.6
11
+ comm==0.2.2
12
+ contourpy==1.2.1
13
+ cycler==0.12.1
14
+ debugpy==1.8.2
15
+ decorator==5.1.1
16
+ dnspython==2.6.1
17
+ email_validator==2.2.0
18
+ embed_anything==0.1.21
19
+ exceptiongroup==1.2.2
20
+ executing==2.0.1
21
+ fastapi==0.111.1
22
+ fastapi-cli==0.0.4
23
+ ffmpy==0.3.2
24
+ filelock==3.15.4
25
+ fonttools==4.53.1
26
+ fsspec==2024.6.1
27
+ gradio==4.38.1
28
+ gradio_client==1.1.0
29
+ h11==0.14.0
30
+ httpcore==1.0.5
31
+ httptools==0.6.1
32
+ httpx==0.27.0
33
+ huggingface-hub==0.23.5
34
+ idna==3.7
35
+ importlib_metadata==8.0.0
36
+ importlib_resources==6.4.0
37
+ ipykernel==6.29.5
38
+ ipython==8.26.0
39
+ jedi==0.19.1
40
+ Jinja2==3.1.4
41
+ jsonschema==4.23.0
42
+ jsonschema-specifications==2023.12.1
43
+ jupyter_client==8.6.2
44
+ jupyter_core==5.7.2
45
+ kiwisolver==1.4.5
46
+ markdown-it-py==3.0.0
47
+ MarkupSafe==2.1.5
48
+ matplotlib==3.9.1
49
+ matplotlib-inline==0.1.7
50
+ mdurl==0.1.2
51
+ nest_asyncio==1.6.0
52
+ numpy==2.0.0
53
+ orjson==3.10.6
54
+ packaging==24.1
55
+ pandas==2.2.2
56
+ parso==0.8.4
57
+ pickleshare==0.7.5
58
+ pillow==10.4.0
59
+ pinecone-client==4.1.2
60
+ pinecone-plugin-interface==0.0.7
61
+ pip==24.0
62
+ platformdirs==4.2.2
63
+ prompt_toolkit==3.0.47
64
+ psutil==6.0.0
65
+ pure-eval==0.2.2
66
+ pydantic==2.8.2
67
+ pydantic_core==2.20.1
68
+ pydub==0.25.1
69
+ Pygments==2.18.0
70
+ pyparsing==3.1.2
71
+ python-dateutil==2.9.0
72
+ python-dotenv==1.0.1
73
+ python-multipart==0.0.9
74
+ pytz==2024.1
75
+ pywin32==306
76
+ PyYAML==6.0.1
77
+ pyzmq==26.0.3
78
+ referencing==0.35.1
79
+ requests==2.32.3
80
+ rich==13.7.1
81
+ rpds-py==0.19.0
82
+ ruff==0.5.2
83
+ semantic-version==2.10.0
84
+ setuptools==70.3.0
85
+ shellingham==1.5.4
86
+ six==1.16.0
87
+ sniffio==1.3.1
88
+ stack-data==0.6.2
89
+ starlette==0.37.2
90
+ tomlkit==0.12.0
91
+ toolz==0.12.1
92
+ tornado==6.4.1
93
+ tqdm==4.66.4
94
+ traitlets==5.14.3
95
+ typer==0.12.3
96
+ typing_extensions==4.12.2
97
+ tzdata==2024.1
98
+ urllib3==2.2.2
99
+ uvicorn==0.30.1
100
+ watchfiles==0.22.0
101
+ wcwidth==0.2.13
102
+ websockets==11.0.3
103
+ wheel==0.43.0
104
+ zipp==3.19.2
test.ipynb ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "name": "stderr",
10
+ "output_type": "stream",
11
+ "text": [
12
+ "C:\\Users\\arbal\\AppData\\Local\\Temp\\ipykernel_27040\\3276458500.py:3: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
13
+ " from tqdm.autonotebook import tqdm\n"
14
+ ]
15
+ }
16
+ ],
17
+ "source": [
18
+ "import embed_anything\n",
19
+ "from embed_anything import EmbedData\n",
20
+ "from tqdm.autonotebook import tqdm\n",
21
+ "from pinecone import Pinecone, ServerlessSpec\n",
22
+ "import numpy as np\n",
23
+ "import os\n",
24
+ "from pinecone import PineconeApiException\n",
25
+ "import uuid"
26
+ ]
27
+ },
28
+ {
29
+ "cell_type": "code",
30
+ "execution_count": 2,
31
+ "metadata": {},
32
+ "outputs": [],
33
+ "source": [
34
+ "audio_files = [\"examples/samples_hp0.wav\", \"examples/samples_gb0.wav\"]"
35
+ ]
36
+ },
37
+ {
38
+ "cell_type": "code",
39
+ "execution_count": 3,
40
+ "metadata": {},
41
+ "outputs": [],
42
+ "source": [
43
+ "embeddings: list[list[EmbedData]] = []"
44
+ ]
45
+ },
46
+ {
47
+ "cell_type": "code",
48
+ "execution_count": 4,
49
+ "metadata": {},
50
+ "outputs": [],
51
+ "source": [
52
+ "for file in audio_files:\n",
53
+ " embedding = embed_anything.embed_file(file, \"Whisper-Jina\")\n",
54
+ " embeddings.append(embedding)"
55
+ ]
56
+ },
57
+ {
58
+ "cell_type": "code",
59
+ "execution_count": 96,
60
+ "metadata": {},
61
+ "outputs": [],
62
+ "source": [
63
+ "pc = Pinecone(api_key=os.environ.get(\"PINECONE_API_KEY\"))\n",
64
+ "pc.delete_index(\"search-in-audio\")\n",
65
+ "try:\n",
66
+ " index = pc.create_index(\n",
67
+ " name=\"search-in-audio\",\n",
68
+ " dimension=768, # Replace with your model dimensions\n",
69
+ " metric=\"cosine\", # Replace with your model metric\n",
70
+ " spec=ServerlessSpec(\n",
71
+ " cloud=\"aws\",\n",
72
+ " region=\"us-east-1\"\n",
73
+ " ) \n",
74
+ " )\n",
75
+ " index = pc.Index('search-in-audio')\n",
76
+ "except(PineconeApiException) as e:\n",
77
+ " index = pc.Index('search-in-audio')\n",
78
+ " if e.status == 409:\n",
79
+ " print(\"Index already exists\")\n",
80
+ " \n",
81
+ " else: print(e)"
82
+ ]
83
+ },
84
+ {
85
+ "cell_type": "code",
86
+ "execution_count": 97,
87
+ "metadata": {},
88
+ "outputs": [],
89
+ "source": [
90
+ "## convert embeddings which is of the form EmbedData : text, embedding, metadata to the form required by pinecone which is id, values, metadata\n",
91
+ "import re\n",
92
+ "def convert_to_pinecone_format(embeddings: list[list[EmbedData]]):\n",
93
+ " data = []\n",
94
+ " for i, embedding in enumerate(embeddings):\n",
95
+ " for j, emb in enumerate(embedding):\n",
96
+ " data.append({\"id\": str(uuid.uuid4()), \"values\": emb.embedding, \"metadata\": {\"text\": emb.text, \"start\": emb.metadata[\"start\"], \"end\": emb.metadata[\"end\"], \"file\": re.split(r'/|\\\\',emb.metadata[\"file_name\"])[-1]}})\n",
97
+ " return data"
98
+ ]
99
+ },
100
+ {
101
+ "cell_type": "code",
102
+ "execution_count": 98,
103
+ "metadata": {},
104
+ "outputs": [
105
+ {
106
+ "data": {
107
+ "text/plain": [
108
+ "{'upserted_count': 15}"
109
+ ]
110
+ },
111
+ "execution_count": 98,
112
+ "metadata": {},
113
+ "output_type": "execute_result"
114
+ }
115
+ ],
116
+ "source": [
117
+ "data = convert_to_pinecone_format(embeddings)\n",
118
+ "index.upsert(data)"
119
+ ]
120
+ },
121
+ {
122
+ "cell_type": "code",
123
+ "execution_count": 99,
124
+ "metadata": {},
125
+ "outputs": [],
126
+ "source": [
127
+ "query = embed_anything.embed_query(['united states'], \"Jina\")[0]"
128
+ ]
129
+ },
130
+ {
131
+ "cell_type": "code",
132
+ "execution_count": 100,
133
+ "metadata": {},
134
+ "outputs": [],
135
+ "source": [
136
+ "result = index.query(vector=query.embedding, top_k=5, include_metadata=True,)\n"
137
+ ]
138
+ },
139
+ {
140
+ "cell_type": "code",
141
+ "execution_count": 101,
142
+ "metadata": {},
143
+ "outputs": [
144
+ {
145
+ "name": "stdout",
146
+ "output_type": "stream",
147
+ "text": [
148
+ "{'end': '120', 'file': 'samples_gb0.wav', 'start': '90', 'text': \" Young democracy from Georgia and Ukraine to Afghanistan and Iraq can look to the United States for proof that self-government can endure and nations that still live under tyranny and oppression can find hope and inspiration in our commitment to liberty. For more than two centuries, Americans have demonstrated the ability of free people to choose their own leaders. Our nation has flourished because of its commitment to trusting the wisdom of our citizenry. In this year's election, we will see this tradition continue and we will be reminded once again\"}\n",
149
+ "{'end': '60', 'file': 'samples_gb0.wav', 'start': '30', 'text': ' The United States was founded on the belief that all men are created equal. Every election day, millions of Americans of all races, religions and backgrounds step into voting booths throughout the nation, whether they are richer, poor, older, young. Each of them has an equal share in choosing the path that our country will take. And every ballot they cast is a reminder that our founding principles are alive and well. Voting is one of the great privileges of a'}\n",
150
+ "{'end': '30', 'file': 'samples_gb0.wav', 'start': '0', 'text': \" Good morning. This Tuesday is Election Day. After months of spirited debate in vigorous campaigning, the time has come for Americans to make important decisions about our nation's future and encourage all Americans to go to the polls and vote. Election season brings out the spirit of competition between our political parties. And that competition is an essential part of a healthy democracy. But as the campaigns come to a close, Republicans, Democrats, and independents can find common ground on at least one point. Our system of\"}\n",
151
+ "{'end': '300', 'file': 'samples_hp0.wav', 'start': '270', 'text': ' TML'}\n",
152
+ "{'end': '30', 'file': 'samples_hp0.wav', 'start': '0', 'text': ' Henry F. Phillips from Wikipedia, the free encyclopedia at en.wickipedia.org.'}\n"
153
+ ]
154
+ }
155
+ ],
156
+ "source": [
157
+ "for res in result.matches:\n",
158
+ " print(res.metadata)"
159
+ ]
160
+ },
161
+ {
162
+ "cell_type": "code",
163
+ "execution_count": 104,
164
+ "metadata": {},
165
+ "outputs": [
166
+ {
167
+ "name": "stdout",
168
+ "output_type": "stream",
169
+ "text": [
170
+ "Running on local URL: http://127.0.0.1:7899\n",
171
+ "\n",
172
+ "To create a public link, set `share=True` in `launch()`.\n"
173
+ ]
174
+ },
175
+ {
176
+ "data": {
177
+ "text/html": [
178
+ "<div><iframe src=\"http://127.0.0.1:7899/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
179
+ ],
180
+ "text/plain": [
181
+ "<IPython.core.display.HTML object>"
182
+ ]
183
+ },
184
+ "metadata": {},
185
+ "output_type": "display_data"
186
+ },
187
+ {
188
+ "data": {
189
+ "text/plain": []
190
+ },
191
+ "execution_count": 104,
192
+ "metadata": {},
193
+ "output_type": "execute_result"
194
+ }
195
+ ],
196
+ "source": [
197
+ "import gradio as gr\n",
198
+ "files = [\"samples_hp0.wav\", \"samples_gb0.wav\"]\n",
199
+ "def search(query, audio):\n",
200
+ "\n",
201
+ " results = []\n",
202
+ " query = embed_anything.embed_query([query], \"Jina\")[0]\n",
203
+ "\n",
204
+ " if re.split(r'/|\\\\',audio)[-1] not in files:\n",
205
+ " print(file, re.split(r'/|\\\\',audio)[-1])\n",
206
+ " embeddings = embed_anything.embed_file(audio, \"Whisper-Jina\")\n",
207
+ " embeddings = convert_to_pinecone_format([embeddings])\n",
208
+ " index.upsert(embeddings)\n",
209
+ "\n",
210
+ " files.append(re.split(r'/|\\\\',audio)[-1])\n",
211
+ "\n",
212
+ "\n",
213
+ " result = index.query(vector=query.embedding, top_k=5, include_metadata=True,)\n",
214
+ " for res in result.matches:\n",
215
+ " results.append(res.metadata)\n",
216
+ " \n",
217
+ " formatted_results = []\n",
218
+ " for result in results:\n",
219
+ " display_text = f'''\n",
220
+ " \n",
221
+ " `File: {result['file']}`\n",
222
+ " \n",
223
+ " `Start: {result['start']}`\n",
224
+ " \n",
225
+ " `End: {result['end']}`\n",
226
+ " \n",
227
+ " Text: {result['text']}''' \n",
228
+ " formatted_results.append(display_text)\n",
229
+ "\n",
230
+ " return formatted_results[0], results[0]['file'], formatted_results[1], results[1]['file'], formatted_results[2], results[2]['file']\n",
231
+ "\n",
232
+ "demo = gr.Interface(\n",
233
+ " fn=search,\n",
234
+ " inputs=[\"text\", gr.Audio(label='Audio', type = 'filepath')],\n",
235
+ " outputs=[\n",
236
+ " \n",
237
+ " gr.Markdown(label=\"Text\"), gr.Audio(label=\"Audio\", type=\"filepath\"),\n",
238
+ " gr.Markdown(label=\"Text\"), gr.Audio(label=\"Audio\", type=\"filepath\"),\n",
239
+ " gr.Markdown(label=\"Text\"), gr.Audio(label=\"Audio\", type=\"filepath\")\n",
240
+ " ],\n",
241
+ " examples=[[\"screwdriver\", \"examples/samples_hp0.wav\"], [\"united states\", \"examples/samples_gb0.wav\"], [\"united states\", \"examples/samples_hp0.wav\"]],\n",
242
+ ")\n",
243
+ "demo.launch()"
244
+ ]
245
+ },
246
+ {
247
+ "cell_type": "code",
248
+ "execution_count": 89,
249
+ "metadata": {},
250
+ "outputs": [
251
+ {
252
+ "data": {
253
+ "text/plain": [
254
+ "False"
255
+ ]
256
+ },
257
+ "execution_count": 89,
258
+ "metadata": {},
259
+ "output_type": "execute_result"
260
+ }
261
+ ],
262
+ "source": [
263
+ "audio = \"C:/Users/arbal/AppData/Local/Temp/gradio/c0490405f0fef485a043991c6a9d6b83f006db51/samples_hp0.wav\"\n",
264
+ "\"samples_hp0.wav\" not in audio"
265
+ ]
266
+ },
267
+ {
268
+ "cell_type": "code",
269
+ "execution_count": 94,
270
+ "metadata": {},
271
+ "outputs": [
272
+ {
273
+ "ename": "SyntaxError",
274
+ "evalue": "(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \\UXXXXXXXX escape (1955374795.py, line 1)",
275
+ "output_type": "error",
276
+ "traceback": [
277
+ "\u001b[1;36m Cell \u001b[1;32mIn[94], line 1\u001b[1;36m\u001b[0m\n\u001b[1;33m if \"samples_hp0.wav\" not in \"C:\\Users\\arbal\\AppData\\Local\\Temp\\gradio\\c0490405f0fef485a043991c6a9d6b83f006db51\\samples_hp0.wav\"\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \\UXXXXXXXX escape\n"
278
+ ]
279
+ }
280
+ ],
281
+ "source": [
282
+ "if \"samples_hp0.wav\" not in \"C:\\Users\\arbal\\AppData\\Local\\Temp\\gradio\\c0490405f0fef485a043991c6a9d6b83f006db51\\samples_hp0.wav\""
283
+ ]
284
+ },
285
+ {
286
+ "cell_type": "code",
287
+ "execution_count": 93,
288
+ "metadata": {},
289
+ "outputs": [
290
+ {
291
+ "data": {
292
+ "text/plain": [
293
+ "'samples_hp0.wav'"
294
+ ]
295
+ },
296
+ "execution_count": 93,
297
+ "metadata": {},
298
+ "output_type": "execute_result"
299
+ }
300
+ ],
301
+ "source": [
302
+ "re.split(r'/|\\\\',audio)[-1]"
303
+ ]
304
+ },
305
+ {
306
+ "cell_type": "code",
307
+ "execution_count": null,
308
+ "metadata": {},
309
+ "outputs": [],
310
+ "source": []
311
+ }
312
+ ],
313
+ "metadata": {
314
+ "kernelspec": {
315
+ "display_name": "embedAnything",
316
+ "language": "python",
317
+ "name": "python3"
318
+ },
319
+ "language_info": {
320
+ "codemirror_mode": {
321
+ "name": "ipython",
322
+ "version": 3
323
+ },
324
+ "file_extension": ".py",
325
+ "mimetype": "text/x-python",
326
+ "name": "python",
327
+ "nbconvert_exporter": "python",
328
+ "pygments_lexer": "ipython3",
329
+ "version": "3.11.9"
330
+ }
331
+ },
332
+ "nbformat": 4,
333
+ "nbformat_minor": 2
334
+ }