From 476dc3f30c014e0d2ebdc46ce0283ddbfe63eeb8 Mon Sep 17 00:00:00 2001
From: VirtuosoQ <2416050435@qq.com>
Date: 星期日, 28 四月 2024 16:37:54 +0800
Subject: [PATCH] 16:37 java_http_client

---
 funasr/models/campplus/utils.py |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/funasr/models/campplus/utils.py b/funasr/models/campplus/utils.py
index 9964356..399be4b 100644
--- a/funasr/models/campplus/utils.py
+++ b/funasr/models/campplus/utils.py
@@ -1,5 +1,8 @@
-# Copyright 3D-Speaker (https://github.com/alibaba-damo-academy/3D-Speaker). All Rights Reserved.
-# Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
+#!/usr/bin/env python3
+# -*- encoding: utf-8 -*-
+# Copyright FunASR (https://github.com/alibaba-damo-academy/FunASR). All Rights Reserved.
+#  MIT License  (https://opensource.org/licenses/MIT)
+# Modified from 3D-Speaker (https://github.com/alibaba-damo-academy/3D-Speaker)
 
 import io
 import os
@@ -14,6 +17,7 @@
 from typing import Generator, Union
 from abc import ABCMeta, abstractmethod
 import torchaudio.compliance.kaldi as Kaldi
+
 from funasr.models.transformer.utils.nets_utils import pad_list
 
 
@@ -173,6 +177,9 @@
     return res
 
 def smooth(res, mindur=1):
+    # if only one segment, return directly
+    if len(res) < 2:
+        return res
     # short segments are assigned to nearest speakers.
     for i in range(len(res)):
         res[i][0] = round(res[i][0], 2)
@@ -208,7 +215,7 @@
             if overlap > max_overlap:
                 max_overlap = overlap
                 sentence_spk = spk
-        d['spk'] = sentence_spk
+        d['spk'] = int(sentence_spk)
         sd_sentence_list.append(d)
     return sd_sentence_list
 

--
Gitblit v1.9.1