File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -233,8 +233,14 @@ def get_duration(self, segment_index=None) -> float:
233
233
The duration in seconds
234
234
"""
235
235
segment_index = self ._check_segment_index (segment_index )
236
- segment_num_samples = self .get_num_samples (segment_index = segment_index )
237
- segment_duration = segment_num_samples / self .get_sampling_frequency ()
236
+
237
+ if self .has_time_vector (segment_index ):
238
+ times = self .get_times (segment_index )
239
+ segment_duration = times [- 1 ] - times [0 ] + (1 / self .get_sampling_frequency ())
240
+ else :
241
+ segment_num_samples = self .get_num_samples (segment_index = segment_index )
242
+ segment_duration = segment_num_samples / self .get_sampling_frequency ()
243
+
238
244
return segment_duration
239
245
240
246
def get_total_duration (self ) -> float :
@@ -246,7 +252,7 @@ def get_total_duration(self) -> float:
246
252
float
247
253
The duration in seconds
248
254
"""
249
- duration = self .get_total_samples () / self .get_sampling_frequency ( )
255
+ duration = sum ([ self .get_duration ( idx ) for idx in self .get_num_segments ()] )
250
256
return duration
251
257
252
258
def get_memory_size (self , segment_index = None ) -> int :
You can’t perform that action at this time.
0 commit comments