prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [vec][search] update to paddlespeech model
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `demos/audio_searching/src/config.py`
  Content:
  ```
  1 # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 import os
  15 
  16 ############### Milvus Configuration ###############
  17 MILVUS_HOST = os.getenv("MILVUS_HOST", "127.0.0.1")
  18 MILVUS_PORT = int(os.getenv("MILVUS_PORT", "19530"))
  19 VECTOR_DIMENSION = int(os.getenv("VECTOR_DIMENSION", "2048"))
  20 INDEX_FILE_SIZE = int(os.getenv("INDEX_FILE_SIZE", "1024"))
  21 METRIC_TYPE = os.getenv("METRIC_TYPE", "L2")
  22 DEFAULT_TABLE = os.getenv("DEFAULT_TABLE", "audio_table")
  23 TOP_K = int(os.getenv("TOP_K", "10"))
  24 
  25 ############### MySQL Configuration ###############
  26 MYSQL_HOST = os.getenv("MYSQL_HOST", "127.0.0.1")
  27 MYSQL_PORT = int(os.getenv("MYSQL_PORT", "3306"))
  28 MYSQL_USER = os.getenv("MYSQL_USER", "root")
  29 MYSQL_PWD = os.getenv("MYSQL_PWD", "123456")
  30 MYSQL_DB = os.getenv("MYSQL_DB", "mysql")
  31 
  32 ############### Data Path ###############
  33 UPLOAD_PATH = os.getenv("UPLOAD_PATH", "tmp/audio-data")
  34 
  35 ############### Number of Log Files ###############
  36 LOGS_NUM = int(os.getenv("logs_num", "0"))
  37
  ```
  
  Path: `demos/audio_searching/src/encode.py`
  Content:
  ```
  1 # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 import os
  15 
  16 import librosa
  17 import numpy as np
  18 from logs import LOGGER
  19 
  20 
  21 def get_audio_embedding(path):
  22     """
  23     Use vpr_inference to generate embedding of audio
  24     """
  25     try:
  26         RESAMPLE_RATE = 16000
  27         audio, _ = librosa.load(path, sr=RESAMPLE_RATE, mono=True)
  28 
  29         # TODO add infer/python interface to get embedding, now fake it by rand
  30         # vpr = ECAPATDNN(checkpoint_path=None, device='cuda')
  31         # embedding = vpr.inference(audio)
  32         np.random.seed(hash(os.path.basename(path)) % 1000000)
  33         embedding = np.random.rand(1, 2048)
  34         embedding = embedding / np.linalg.norm(embedding)
  35         embedding = embedding.tolist()[0]
  36         return embedding
  37     except Exception as e:
  38         LOGGER.error(f"Error with embedding:{e}")
  39         return None
  40
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/demos/audio_searching/src/config.py b/demos/audio_searching/src/config.py
  --- a/demos/audio_searching/src/config.py
  +++ b/demos/audio_searching/src/config.py
  @@ -16,7 +16,7 @@
   ############### Milvus Configuration ###############
   MILVUS_HOST = os.getenv("MILVUS_HOST", "127.0.0.1")
   MILVUS_PORT = int(os.getenv("MILVUS_PORT", "19530"))
  -VECTOR_DIMENSION = int(os.getenv("VECTOR_DIMENSION", "2048"))
  +VECTOR_DIMENSION = int(os.getenv("VECTOR_DIMENSION", "192"))
   INDEX_FILE_SIZE = int(os.getenv("INDEX_FILE_SIZE", "1024"))
   METRIC_TYPE = os.getenv("METRIC_TYPE", "L2")
   DEFAULT_TABLE = os.getenv("DEFAULT_TABLE", "audio_table")
  diff --git a/demos/audio_searching/src/encode.py b/demos/audio_searching/src/encode.py
  --- a/demos/audio_searching/src/encode.py
  +++ b/demos/audio_searching/src/encode.py
  @@ -15,7 +15,12 @@
   
   import librosa
   import numpy as np
  +from config import DEFAULT_TABLE
  +
   from logs import LOGGER
  +from paddlespeech.cli import VectorExecutor
  +
  +vector_executor = VectorExecutor()
   
   
   def get_audio_embedding(path):
  @@ -23,16 +28,9 @@
       Use vpr_inference to generate embedding of audio
       """
       try:
  -        RESAMPLE_RATE = 16000
  -        audio, _ = librosa.load(path, sr=RESAMPLE_RATE, mono=True)
  -
  -        # TODO add infer/python interface to get embedding, now fake it by rand
  -        # vpr = ECAPATDNN(checkpoint_path=None, device='cuda')
  -        # embedding = vpr.inference(audio)
  -        np.random.seed(hash(os.path.basename(path)) % 1000000)
  -        embedding = np.random.rand(1, 2048)
  +        embedding = vector_executor(audio_file=path)
           embedding = embedding / np.linalg.norm(embedding)
  -        embedding = embedding.tolist()[0]
  +        embedding = embedding.tolist()
           return embedding
       except Exception as e:
           LOGGER.error(f"Error with embedding:{e}")
  
verification_info: {"golden_diff": "diff --git a/demos/audio_searching/src/config.py b/demos/audio_searching/src/config.py\n--- a/demos/audio_searching/src/config.py\n+++ b/demos/audio_searching/src/config.py\n@@ -16,7 +16,7 @@\n ############### Milvus Configuration ###############\n MILVUS_HOST = os.getenv(\"MILVUS_HOST\", \"127.0.0.1\")\n MILVUS_PORT = int(os.getenv(\"MILVUS_PORT\", \"19530\"))\n-VECTOR_DIMENSION = int(os.getenv(\"VECTOR_DIMENSION\", \"2048\"))\n+VECTOR_DIMENSION = int(os.getenv(\"VECTOR_DIMENSION\", \"192\"))\n INDEX_FILE_SIZE = int(os.getenv(\"INDEX_FILE_SIZE\", \"1024\"))\n METRIC_TYPE = os.getenv(\"METRIC_TYPE\", \"L2\")\n DEFAULT_TABLE = os.getenv(\"DEFAULT_TABLE\", \"audio_table\")\ndiff --git a/demos/audio_searching/src/encode.py b/demos/audio_searching/src/encode.py\n--- a/demos/audio_searching/src/encode.py\n+++ b/demos/audio_searching/src/encode.py\n@@ -15,7 +15,12 @@\n \n import librosa\n import numpy as np\n+from config import DEFAULT_TABLE\n+\n from logs import LOGGER\n+from paddlespeech.cli import VectorExecutor\n+\n+vector_executor = VectorExecutor()\n \n \n def get_audio_embedding(path):\n@@ -23,16 +28,9 @@\n     Use vpr_inference to generate embedding of audio\n     \"\"\"\n     try:\n-        RESAMPLE_RATE = 16000\n-        audio, _ = librosa.load(path, sr=RESAMPLE_RATE, mono=True)\n-\n-        # TODO add infer/python interface to get embedding, now fake it by rand\n-        # vpr = ECAPATDNN(checkpoint_path=None, device='cuda')\n-        # embedding = vpr.inference(audio)\n-        np.random.seed(hash(os.path.basename(path)) % 1000000)\n-        embedding = np.random.rand(1, 2048)\n+        embedding = vector_executor(audio_file=path)\n         embedding = embedding / np.linalg.norm(embedding)\n-        embedding = embedding.tolist()[0]\n+        embedding = embedding.tolist()\n         return embedding\n     except Exception as e:\n         LOGGER.error(f\"Error with embedding:{e}\")\n", "issue": "[vec][search] update to paddlespeech model\n\n", "before_files": [{"content": "# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport os\n\n############### Milvus Configuration ###############\nMILVUS_HOST = os.getenv(\"MILVUS_HOST\", \"127.0.0.1\")\nMILVUS_PORT = int(os.getenv(\"MILVUS_PORT\", \"19530\"))\nVECTOR_DIMENSION = int(os.getenv(\"VECTOR_DIMENSION\", \"2048\"))\nINDEX_FILE_SIZE = int(os.getenv(\"INDEX_FILE_SIZE\", \"1024\"))\nMETRIC_TYPE = os.getenv(\"METRIC_TYPE\", \"L2\")\nDEFAULT_TABLE = os.getenv(\"DEFAULT_TABLE\", \"audio_table\")\nTOP_K = int(os.getenv(\"TOP_K\", \"10\"))\n\n############### MySQL Configuration ###############\nMYSQL_HOST = os.getenv(\"MYSQL_HOST\", \"127.0.0.1\")\nMYSQL_PORT = int(os.getenv(\"MYSQL_PORT\", \"3306\"))\nMYSQL_USER = os.getenv(\"MYSQL_USER\", \"root\")\nMYSQL_PWD = os.getenv(\"MYSQL_PWD\", \"123456\")\nMYSQL_DB = os.getenv(\"MYSQL_DB\", \"mysql\")\n\n############### Data Path ###############\nUPLOAD_PATH = os.getenv(\"UPLOAD_PATH\", \"tmp/audio-data\")\n\n############### Number of Log Files ###############\nLOGS_NUM = int(os.getenv(\"logs_num\", \"0\"))\n", "path": "demos/audio_searching/src/config.py"}, {"content": "# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport os\n\nimport librosa\nimport numpy as np\nfrom logs import LOGGER\n\n\ndef get_audio_embedding(path):\n    \"\"\"\n    Use vpr_inference to generate embedding of audio\n    \"\"\"\n    try:\n        RESAMPLE_RATE = 16000\n        audio, _ = librosa.load(path, sr=RESAMPLE_RATE, mono=True)\n\n        # TODO add infer/python interface to get embedding, now fake it by rand\n        # vpr = ECAPATDNN(checkpoint_path=None, device='cuda')\n        # embedding = vpr.inference(audio)\n        np.random.seed(hash(os.path.basename(path)) % 1000000)\n        embedding = np.random.rand(1, 2048)\n        embedding = embedding / np.linalg.norm(embedding)\n        embedding = embedding.tolist()[0]\n        return embedding\n    except Exception as e:\n        LOGGER.error(f\"Error with embedding:{e}\")\n        return None\n", "path": "demos/audio_searching/src/encode.py"}], "after_files": [{"content": "# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport os\n\n############### Milvus Configuration ###############\nMILVUS_HOST = os.getenv(\"MILVUS_HOST\", \"127.0.0.1\")\nMILVUS_PORT = int(os.getenv(\"MILVUS_PORT\", \"19530\"))\nVECTOR_DIMENSION = int(os.getenv(\"VECTOR_DIMENSION\", \"192\"))\nINDEX_FILE_SIZE = int(os.getenv(\"INDEX_FILE_SIZE\", \"1024\"))\nMETRIC_TYPE = os.getenv(\"METRIC_TYPE\", \"L2\")\nDEFAULT_TABLE = os.getenv(\"DEFAULT_TABLE\", \"audio_table\")\nTOP_K = int(os.getenv(\"TOP_K\", \"10\"))\n\n############### MySQL Configuration ###############\nMYSQL_HOST = os.getenv(\"MYSQL_HOST\", \"127.0.0.1\")\nMYSQL_PORT = int(os.getenv(\"MYSQL_PORT\", \"3306\"))\nMYSQL_USER = os.getenv(\"MYSQL_USER\", \"root\")\nMYSQL_PWD = os.getenv(\"MYSQL_PWD\", \"123456\")\nMYSQL_DB = os.getenv(\"MYSQL_DB\", \"mysql\")\n\n############### Data Path ###############\nUPLOAD_PATH = os.getenv(\"UPLOAD_PATH\", \"tmp/audio-data\")\n\n############### Number of Log Files ###############\nLOGS_NUM = int(os.getenv(\"logs_num\", \"0\"))\n", "path": "demos/audio_searching/src/config.py"}, {"content": "# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport os\n\nimport librosa\nimport numpy as np\nfrom config import DEFAULT_TABLE\n\nfrom logs import LOGGER\nfrom paddlespeech.cli import VectorExecutor\n\nvector_executor = VectorExecutor()\n\n\ndef get_audio_embedding(path):\n    \"\"\"\n    Use vpr_inference to generate embedding of audio\n    \"\"\"\n    try:\n        embedding = vector_executor(audio_file=path)\n        embedding = embedding / np.linalg.norm(embedding)\n        embedding = embedding.tolist()\n        return embedding\n    except Exception as e:\n        LOGGER.error(f\"Error with embedding:{e}\")\n        return None\n", "path": "demos/audio_searching/src/encode.py"}]}