fix: local audio files without extension are not added to dictAudioMap
Some checks are pending
SonarCloud / Build and analyze (push) Waiting to run

This commit is contained in:
shenleban tongying 2024-11-18 21:35:15 -05:00 committed by GitHub
parent bb87c55b1a
commit 1fa0771716
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 5 deletions

View file

@ -257,9 +257,14 @@ inline bool isAudioUrl( QUrl const & url )
{
if ( !url.isValid() )
return false;
// Note: we check for forvo sound links explicitly, as they don't have extensions
return ( url.scheme() == "http" || url.scheme() == "https" || url.scheme() == "gdau" )
// gdau links are known to be audios, (sometimes they may not have file extension).
if ( url.scheme() == "gdau" ) {
return true;
}
// Note: we check for forvo sound links explicitly, as they don't have extensions
return ( url.scheme() == "http" || url.scheme() == "https" )
&& ( Filetype::isNameOfSound( url.path().toUtf8().data() ) || url.host() == "apifree.forvo.com" );
}

View file

@ -17,7 +17,7 @@ void PronounceEngine::reset()
}
void PronounceEngine::sendAudio( std::string dictId, QString audioLink )
void PronounceEngine::sendAudio( const std::string & dictId, const QString & audioLink )
{
if ( state == PronounceState::OCCUPIED ) {
return;
@ -29,7 +29,7 @@ void PronounceEngine::sendAudio( std::string dictId, QString audioLink )
QMutexLocker _( &mutex );
dictAudioMap.operator[]( dictId ).push_back( audioLink );
dictAudioMap[ dictId ].append( audioLink );
}
void PronounceEngine::finishDictionary( std::string dictId )

View file

@ -21,7 +21,7 @@ class PronounceEngine: public QObject
public:
explicit PronounceEngine( QObject * parent = nullptr );
void reset();
void sendAudio( std::string dictId, QString audioLink );
void sendAudio( const std::string & dictId, const QString & audioLink );
void finishDictionary( std::string dictId );
signals:
void emitAudio( QString audioLink );