int roadmap_sound_list_add_buf (RoadMapSoundList list, void* buf, size_t size ) { char path[512]; int file_num = list->count; RoadMapFile file; if (list->count == MAX_SOUND_LIST) return SND_LIST_ERR_LIST_FULL; list->buf_list[list->count] = buf; list->buf_list_sizes[list->count] = size; /* * Temporary solution - write the buffer to the file for further playing * AGA */ sprintf( path, "%s/tmp/%d", roadmap_path_tts(), file_num ); if ( file_num == 0 ) { roadmap_path_create( roadmap_path_parent( path, NULL ) ); } file = roadmap_file_open( path, "w" ); roadmap_file_write( file, buf, size ); roadmap_file_close( file ); strncpy_safe( list->list[list->count], path, 512 ); list->count++; return list->count - 1; }
void tts_db_generate_path( const char* voice_id, TtsPath* db_path ) { static char s_voice_id[TTS_VOICE_MAXLEN] = {0}; static unsigned long counter = 0; char path_suffix[TTS_PATH_MAXLEN]; const EpochTimeMicroSec* time_now = roadmap_time_get_epoch_us( NULL ); if ( !db_path ) return; // File name snprintf( path_suffix, sizeof( path_suffix ), "%s//%s//%lu-%lu-%lu.%s", TTS_DB_FILES_ROOT_DIR, voice_id, time_now->epoch_sec, time_now->usec, counter++, TTS_RESULT_FILE_NAME_EXT ); // Full path roadmap_path_format( db_path->path, TTS_PATH_MAXLEN, roadmap_path_tts(), path_suffix ); if ( strcmp( s_voice_id, voice_id ) ) // Save io time { char* parent = roadmap_path_parent( db_path->path, NULL ); strncpy_safe( s_voice_id, voice_id, TTS_VOICE_MAXLEN ); // Create path if not exists roadmap_path_create( parent ); free( parent ); } }